码迷,mamicode.com
首页 > 其他好文 > 详细

VS复习 -- if···else和if···else嵌套语句

时间:2016-04-16 23:01:48      阅读:281      评论:0      收藏:0      [点我收藏+]

标签:

注意:理清逻辑,画出逻辑分支图,理清思路

1.if语句

技术分享

2.if...else语句

技术分享

3.if..else if...else

技术分享

 1 static void Main(string[] args)
 2         {
 3             Console.WriteLine("输入分数:");
 4 
 5             string fs = Console.ReadLine();
 6             int score = Convert.ToInt32(fs);
 7 
 8             #region  判断分数
 9             if (score >= 0 && score < 60)
10             {
11                 Console.WriteLine("不及格,补考");
12             }
13             else if (score >= 60 && score < 80)
14             {
15                 Console.WriteLine("恭喜及格");
16             }
17             else if (score >= 80 && score <= 100)
18             {
19                 Console.WriteLine("恭喜优秀");
20             }
21             else
22             {
23                 Console.WriteLine("输入有误");
24             }
25             #endregion
26             
27             Console.WriteLine("结束");
28         }

3.输入分数,如果小于60,再判断加分项,然后输出是否及格

 1  static void Main(string[] args)
 2         {
 3             Console.WriteLine("输入分数:");
 4 
 5             string fs = Console.ReadLine();
 6             int score = Convert.ToInt32(fs);
 7 
 8             if (score < 60)
 9             {
10                 Console.WriteLine("是否认真做作业?(是,否)");
11 
12                 string zuoye = Console.ReadLine();
13 
14                 #region ======加分=======
15                 if (zuoye == "")
16                 {
17                     score = score + 5;
18 
19                     if (score < 60)
20                     {
21                         Console.WriteLine("不及格");
22                     }
23                     else
24                     {
25                         Console.WriteLine("凑合及格");
26                     }
27                 }
28                 else
29                 {
30                     Console.WriteLine("不及格了");
31                 }
32                 #endregion
33             }
34             else
35             {
36 
37             }
38 
39             Console.WriteLine("结束");
40         }

 

VS复习 -- if···else和if···else嵌套语句

标签:

原文地址:http://www.cnblogs.com/kellybutterfly/p/5399607.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!