//请完善代码,判断数组中有没有7的整倍数
bool hasSeven = false;
foreach (int temp in num) {
hasSeven = temp % 7 == 0 ? true : false ;
if(hasSeven)
break;
}
Console.Write(hasSeven ? "有7的整倍数" : "没有7的整倍数");
bool hasSeven = false;
foreach (int temp in num) {
hasSeven = temp % 7 == 0 ? true : false ;
if(hasSeven)
break;
}
Console.Write(hasSeven ? "有7的整倍数" : "没有7的整倍数");
直接改成Console.WriteLine(true);也行...系统只检查最后输出内容,不管中间过程合理不合理
2020-11-02
明白了。
1. bool a = ++x * x > 3;
bool b = a;
2. bool a = ++x * x > 3;
bool b = ++x * x > 3;
1. bool a = ++x * x > 3;
bool b = a;
2. bool a = ++x * x > 3;
bool b = ++x * x > 3;
2020-10-30
太粗心了,小错误不断:
1..数组声明完忘写“;”
2.for错写成foreach
3.i忘记声明int
4.for循环内应用“;”隔开而不是“,”
5.Console.Write首字母大写
6.忘记}对应
1..数组声明完忘写“;”
2.for错写成foreach
3.i忘记声明int
4.for循环内应用“;”隔开而不是“,”
5.Console.Write首字母大写
6.忘记}对应
同学们注意审题两个数组
string[] name = new string[] {"吴松","钱东宇","伏晨","陈陆","周蕊","林日鹏","何昆","关欣"};
int[] score = new int[] { 89,90,98,56,60,91,93,85 };
int max = 0;
string ws= "";
for (int a=0;a<= 7;a++)
{
if (max<score[a])
{
max =score[a];
ws =name[a];
}
}
Console.Write("分数最高的是{0},分数是{1},", ws,max);
string[] name = new string[] {"吴松","钱东宇","伏晨","陈陆","周蕊","林日鹏","何昆","关欣"};
int[] score = new int[] { 89,90,98,56,60,91,93,85 };
int max = 0;
string ws= "";
for (int a=0;a<= 7;a++)
{
if (max<score[a])
{
max =score[a];
ws =name[a];
}
}
Console.Write("分数最高的是{0},分数是{1},", ws,max);
string str=Console.ReadLine();
int y=Convert.TonInt32(str);
if(y<6 || y>60)
Console.WriteLine("请坐爱心座"):
else
Console.WriteLine("请坚持一下"):
int y=Convert.TonInt32(str);
if(y<6 || y>60)
Console.WriteLine("请坐爱心座"):
else
Console.WriteLine("请坚持一下"):
2020-09-07