//請完善代碼,判斷數組中有沒有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