int x,sum,temp;
x = 30;
temp = x;
sum = 0;
while (x > 0)
{
if (x % 2 == 1)
sum += x;
x--;
}
Console.WriteLine("1到{0}的奇数和为{1}",temp,sum);
x = 30;
temp = x;
sum = 0;
while (x > 0)
{
if (x % 2 == 1)
sum += x;
x--;
}
Console.WriteLine("1到{0}的奇数和为{1}",temp,sum);
2018-04-29
最新回答 / 廿一支烟
在write(XXX);在XXX中是可以填入任意类型的代码数据的,因为""表示的是一个字符串类型,所以里面的数据就是固定的;给你举一个简单的例子:int a =1;int b =2;Console.Write("a+b");//这个语句的输出结果是:a+bConsole.Write(a+b);//这个语句的输出结果是:3
2018-04-28
int temp =0;
string []arr = new string[]{"吴松","钱东宇","伏晨","陈陆","周蕊","林日鹏","何琨","关欣"};
int []arr1 = new int[]{89,90,98,56,60,91,93,85} ;
for(int i =0;i<8;i++)
{
if (arr1[temp] < arr1[i])
temp = i;
}
Console.WriteLine("分数最高的是{0},分数是{1},",arr[temp],arr1[temp]);
string []arr = new string[]{"吴松","钱东宇","伏晨","陈陆","周蕊","林日鹏","何琨","关欣"};
int []arr1 = new int[]{89,90,98,56,60,91,93,85} ;
for(int i =0;i<8;i++)
{
if (arr1[temp] < arr1[i])
temp = i;
}
Console.WriteLine("分数最高的是{0},分数是{1},",arr[temp],arr1[temp]);
已采纳回答 / 慕桂英7241084
有两个循环,外层循环控制打印多少行/内层循环控制什么时候打印 O 什么时候打印 . /观察每一行的规律只有x=y或者x+y=8时打印 O 否则打印 .
2018-04-27
{
for (int y = 1; y <= 7; y++)
{
for (int x = 1; x <= 7; x++)
{
if(x > y)
break;
Console.Write(x);
}
Console.WriteLine();
for (int y = 1; y <= 7; y++)
{
for (int x = 1; x <= 7; x++)
{
if(x > y)
break;
Console.Write(x);
}
Console.WriteLine();
2018-04-27
最赞回答 / 慕盖茨7849978
第一个if语句内无需再用一个for循环寻找该索引,直接在第一个for循环结束之后Console.Write("分数最高的是"+name[index]+",分数是:"score[index])因为此时的index是最高分数的索引
2018-04-25