while语句的练习一

今天学习了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();
            }
            
        }
    }
}

  

posted @ 2020-01-03 13:03  白发小学生  阅读(327)  评论(0编辑  收藏  举报