题1:
int a = 1, b = 3;
a = a++ + b % 2;
int a = 1, b = 3;
a = a++ + b % 2;
//a = 2
题2:
int a = 1,b = 4;
a = a + b/(++a - b);
int a = 1,b = 4;
a = a+ b /(++a - b);
a = -1
题3:
123 #lanou @123 @lanou lanou$keji int 12_beijing _123 _lanou@123 Int
以上变量名中合法的变量名有哪些?
@lanou , _123, Int
题4:
已知一个圆半径为3.5,声明一个变量名radius存储该圆半径,要求输出该圆的半径、周长和面积。
float radius = 3.5f;
const float PI = 3.14f;
Console.WriteLine ("radius = {0},perimeter {1},area = {2}",radius,PI*2*radius,PI*radius*radius);
//Console.WriteLine ("{0}",Math.Pow(2,3)); //2的3次方
题5:
祖父今年65岁,3个孙子分别15、13、9岁,问多少年后3个孙子的年龄之和等于祖父?
int a = 65, b = 15, c = 13, d = 9;
for (int e = 0; true;e++) {
if (a + e == b + c + d + 3 * e) {
Console.WriteLine ("{0}",e);
break;
}
}
int x = 1;
while(true){
if(65+x == 15+13+9+3*x){
Console.WriteLine ("经{0}年后等于",x);
break;
}
++x;
}