VS 复习,if...else if..else 和if..else的嵌套学习

内容;if..else 输入:准确找到要计算的值,通过“if..else”进行分类,一般在分类时是最容易分不清,注意要分清楚问的重点;例分数两种情况1)及格(在及格的前提下优秀用if嵌套if),2)补考,然后就是结束。
输出:记住你输入的是字符,并非电脑认可的数字,所以再输入时要使用转义字符:例 以int,为例int.Parse()或Convert.Toint。还有doubie,fioat,等;
1.

 


 static void Main666(string[] args)
        {
            Console.WriteLine("输入分数:");

string fs = Console.ReadLine(); int score = Convert.ToInt32(fs); if (score < 60) { Console.WriteLine("是否认真做作业?(是,否)"); string zuoye = Console.ReadLine(); #region ======加分======= if (zuoye == "") { score = score + 5; if (score < 60) { Console.WriteLine("不及格"); } else { Console.WriteLine("凑合及格"); } } else { Console.WriteLine("不及格了"); } #endregion } else { } Console.WriteLine("结束"); } static void Main222(string[] args) { Console.WriteLine("输入分数:"); string fs = Console.ReadLine(); int score = Convert.ToInt32(fs); #region 判断分数 if (score >= 0 && score < 60) { Console.WriteLine("不及格,补考"); } else if (score >= 60 && score < 80) { Console.WriteLine("恭喜及格"); } else if (score >= 80 && score <= 100) { Console.WriteLine("恭喜优秀"); } else { Console.WriteLine("输入有误"); } #endregion Console.WriteLine("结束"); } static void Main111(string[] args) { int a = 10; int b = 5; int c = (a++) + b; int d = (++a) + b; Console.WriteLine(a); Console.WriteLine(c); Console.WriteLine(d); } static void abc(string[] args) { Console.WriteLine("输入分数:"); string fs = Console.ReadLine(); int score = Convert.ToInt32(fs); if (score < 60) { Console.WriteLine("不及格,需要补考"); } Console.WriteLine("结束"); }
原文地址:https://www.cnblogs.com/koker/p/5399547.html