int x = 2;
do
{
x++;
Console.Write(x+" ");
}
while(x>2&&x<=4);
先输出x=2+1=3 , 判断3>2并且3<=4,true 循环x=3+1=4,判断4>2并且4<=4,循环输出x=4+1=5,判断false,结束
do
{
x++;
Console.Write(x+" ");
}
while(x>2&&x<=4);
先输出x=2+1=3 , 判断3>2并且3<=4,true 循环x=3+1=4,判断4>2并且4<=4,循环输出x=4+1=5,判断false,结束
2017-05-15
int x = 2;
do
{
x++;
Console.Write(x+" ");
}
while(x>2&&x<=4);
do
{
x++;
Console.Write(x+" ");
}
while(x>2&&x<=4);
2017-05-15
int x = 1;
int sum = 0;//和,初始化为0
while (x <= 30)//循环条件
{
if (x%2!=0)//筛选条件
sum += x;
x++;
}
Console.Write("1-30奇数的和:"+sum);
int sum = 0;//和,初始化为0
while (x <= 30)//循环条件
{
if (x%2!=0)//筛选条件
sum += x;
x++;
}
Console.Write("1-30奇数的和:"+sum);
2017-05-15
int x = 5;
int y = 6;
if (x >= y){
if (x >= 5)
Console.WriteLine("5");
}else{
if (y >= 6)
Console.WriteLine("6");
else
Console.WriteLine("7");
}
int y = 6;
if (x >= y){
if (x >= 5)
Console.WriteLine("5");
}else{
if (y >= 6)
Console.WriteLine("6");
else
Console.WriteLine("7");
}
2017-05-15