• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
kelly凯丽
博客园    首页    新随笔    联系   管理    订阅  订阅
VS复习 -- if···else和if···else嵌套语句

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

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         }

 

posted on 2016-04-16 22:29  kelly凯丽  阅读(1168)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3