zoukankan      html  css  js  c++  java
  • 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         }
  • 相关阅读:
    解析Java反射java.lang.IllegalArgumentException: wrong number of arguments
    java中参数" ..."的用法和意思
    Synchronized方法锁、对象锁、类锁区别
    瀚云平台kafka简单原理
    ReflectionUtils.invokeMethod的作用
    实用———springmvc接收参数校验
    卷积神经网络CNN
    第一个TensorFlow程序
    TF从文件中读取数据
    TF基础5
  • 原文地址:https://www.cnblogs.com/kellybutterfly/p/5399607.html
Copyright © 2011-2022 走看看