Microsoft Windows 7 Home Premium (OS)
Microsoft Visual C# 2010 Express Edition (IDE)
プログラミング言語 (Microsoft Visual C#)
アプリケーション (コンソールアプリケーション)
"初めてのC# 第2版"のp.85、5章(実行制御)の5.5 練習問題 5-1を解いてみる。
5-1
using System;
class MainClass
{
static void Main()
{
int n = 1, m = 1, l = 1;
Console.WriteLine("while loop");
while (n <= 10)
{
Console.WriteLine("カウンター値: {0}", n);
n++;
}
Console.WriteLine("\ndo...while loop");
do
{
Console.WriteLine("カウンター値: {0}", m);
m++;
} while (m <= 10);
Console.WriteLine("\nfor loop");
for (; l <= 10; l++)
{
Console.WriteLine("カウンター値: {0}", l);
}
}
}
0 コメント:
コメントを投稿