标签:
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);
}
标签:
原文地址:http://www.cnblogs.com/xjt360/p/4304346.html