码迷,mamicode.com
首页 > Web开发 > 详细

.net 基础

时间:2015-02-27 21:31:17      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:

1、  说出以下代码的运行结果,并分析:

public static void Main(String[] args) {

        int a = 0;

        int b = 2;

        int c = 4;

        a += b += c += 6;  

        System.Console.WriteLine("c="+c);

        System.Console.WriteLine("b="+b);

        System.Console.WriteLine("a="+a);

    }

2 public static void Main(String[] args) {

           int a = 2;

              if( a%2 == 0 ? false : true ){

                     System.Console.WriteLine("学习");

              }else{

                     System.Console.WriteLine("不学习");   

              }

    }

 

 3  public static void Main(String[] args) {

           int a = 2;

              if( a++ > 2 && ++a > 2 ){   

  }

       if( a++ < 2 || ++a > 2){ 

              }

              System.Console.WriteLine("a="+a); //a=5   

    }

   4    public static void Main(String[] args) {

          outer:for (int i = 0; i < 5; i++) {

                     for (int j = i; j < 5; j++) {

                            System.Console.Write("-");

                            goto outer;                    }

                     System.Console.Write("\r\n"); 

              }

       }

5 public static void Main(String[] args) {

           bool flag = true;

              for (int i = 0; i < 5 && flag; i++) {

                     for (int j = i; j < 5; j++) {

                            System.Console.Write("-");

                            flag = false ;

                     break;

                     }

                     System.Console.Write("\r\n");             }

  }

       

6 public static void Main(String[] args) {

                  int i;

                  int j;

                     for(i=0,j=5; i < j; i++,j--){

                            System.Console.WriteLine("i="+i); }

                     System.Console.WriteLine("结束后i="+i);

                     System.Console.WriteLine("结束后j="+j);  

       }

.net 基础

标签:

原文地址:http://www.cnblogs.com/xjt360/p/4304346.html

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