using System;
using System.Collections.Generic;
using System.Text;
namespace KnowledgePoint
{
class _14_Ex_While
{
static void Main()
{
string answer = "";
int i = 1;
while (!"y".Equals(answer) && i <= 10)
{
Console.WriteLine("询问次数{0}", i);
Console.Write("老师:这道题你听懂了么?(y/n)");
Console.Write("\n我:");
if ((answer = Console.ReadLine()).Equals("y"))
{
Console.WriteLine("老师:嗯,很好,放学吧!");
break;
}
if (i == 10)
{
Console.WriteLine("\n老师:还是不会吗?今天就到此为止吧,先放学!");
}
i++;
}
Console.ReadKey();
}
}
}
C#老师提问学生回答(回答y或询问次数达10次停止)
最新推荐文章于 2022-08-03 18:34:39 发布