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 ();             

    */            

  • 相关阅读:
    Servlet介绍(一)
    iOS Dev (50)用代码实现图片加圆角
    Codeforces Round #265 (Div. 2) D. Restore Cube 立方体推断
    JVM:垃圾回收机制和调优手段
    Memcachedclient-XMemcached使用
    JVM中类的卸载机制
    血型统计
    iOS 事件传递及响应过程
    java 对象参数去空格方式
    spring aop 一个挡板例子
  • 原文地址:https://www.cnblogs.com/huaze/p/4024182.html
Copyright © 2011-2022 走看看