zoukankan      html  css  js  c++  java
  • 语句(switch语句及其内case , break)

     /* C#:语句     判断,循环,形成循环的分支和循环                

    选择控制:if    else,     switch    case                

    选择控制:while,do,for.foreach                

    跳转语句:break,continue                

    异常处理:try,catch,finally             

    */            /* int casezhi = 1;            

    switch (casezhi)    //小括号内是一个数据类型的值           

      {                 //case 后面加空格,之后写上跟小括号内对应类型的 可能出现的值              

       case 1:                    

       Console.Write("");                  

       break;         //跳转语句。  跳出 包含break 最近的{}!               

      case 2:                    

       Console .Write ("");                    

       break;                

       default :                       

      Console.Write("");                 

        break;            

    }            

    Console.ReadLine();*/            

               /* //练习,判断2014年a月第b天是这一年的第几天        

         Console.WriteLine("输入月:");           

      int a = int.Parse(Console.ReadLine());          

       Console.WriteLine("输入日:");        

        int b = int.Parse(Console.ReadLine());                

       int c=1;

                switch (a)          

       {                 case 1:

                        c=b; //前面已经创建了int c,所以这里不能再创建int c=b,可以直接赋值即c=b.                        

                          break;             //必须有    break

                            case 2:                   

                            c = 31 + b;                

                           break;             

                           case 3:                  

                           c = 31 +28+ b;               

                             break;              

                              case 4:            

                            c = 31 + 28 +30+ b;             

                                break;

                              case 5:

                            c = 31 + 28 +31+30+ b;

                               break;

                    case 6:                           c = 31 + 28 +31+30+31+ b;                                 break;                

                    case 7:                c = 31 + 28 + 31 + 30 + 31 + 30 + b;                                break;                 case 8:             c = 31 + 28 + 31 + 30 + 31 + 30 +31+ b;                             break;                 case 9:               c = 31 + 28 + 31 + 30 + 31 + 30 + 31 +31 +b;                     break;                 case 10:          c= 31 + 28 + 31 + 30 + 31 + 30 + 31 +31+30+ b;                     break;                 case 11:          c = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 +31+ b;         break;

                           default:           // 最后的例子!

                        c = 31 +28+31+30+31+30+31+31+30+31+30+ b;

                        break;

     }             //Console.Write("这是第" + c + "天");              //注意引用格式!                Console.WriteLine("这是第" + c.ToString()  + "天");//.ToString()表示把引用的c转义为字符串型!Console.ReadLine ();             

    */            

  • 相关阅读:
    【转载】HBase 数据库检索性能优化策略
    C语言结构
    c语言之sizeof总结
    C语言之Static
    转帖子:测试专家10年软件测试工作总结
    Word恢复文本转换器-修复损坏的WORD文件
    蓝桥杯 格子刷油漆
    小结博弈
    牛客寒假算法基础集训营6 E 海啸
    牛客寒假算法基础集训营4 F Applese 的大奖
  • 原文地址:https://www.cnblogs.com/huaze/p/4024182.html
Copyright © 2011-2022 走看看