今天學習了while陳述句,自己想了一道題,試著練習,改了幾次之后除錯通過:
學生做題,如果全部都做對了,那么會得到老師的夸獎,如果做錯了,那么每道題要罰抄十遍:
namespace _999_1錯題罰抄
{
class Program
{
/// <summary>
/// 如果做題做錯一道那么罰抄10次,每錯一道題都罰抄10次
///
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
int i = 0;
int j = 0;
int x = 0;
Console.WriteLine("請輸入你做錯題的數量:");
i=Convert.ToInt32(Console.ReadLine());
//x = i;
if(i==0)
{
Console.WriteLine("做得不錯,不用罰抄了!!!");
Console.ReadKey();
}
else
{
while (x < i)
{
//Console.WriteLine("現在開始抄寫第{0}道題",x+1);
while (j < 10)
{
Console.WriteLine("抄寫第{0}道題的第{1}遍;",x+1,j+1);
j++;
}
j = 0;
x++;
}
Console.ReadKey();
}
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/82965.html
標籤:C#
上一篇:while陳述句的使用
下一篇:正則運算式基本用法
