為什么出錯?再vs里沒錯?
?int[] num = new int[] { 3,34,43,2,11,19,30,55,20};
? ? ? ? ? ? bool hasseven=false;
? ? ? ? ? ? //請完善代碼,判斷數組中有沒有7的整倍數
? ? ? ? ? ? foreach (int x in num)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (x%7==0)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? hasseven=true;
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ??
? ? ? ? ? ? if(hasseven)
? ? ? ? ? ? {
? ? ? ? ? ? ? ?Console.Write("有");
? ? ? ? ? ? }
? ? ? ? ? ? ??
? ? ? ? ? ??
? ? ? ? ? ? else
? ? ? ? ? ? {
? ? ? ? ? ? ? ? ?Console.Write("沒有7的整倍數");
? ? ? ? ? ? }
2020-08-11
Console.Write("有");? 和? ?Console.Write("沒有7的整倍數");? ?
這兩個后面的分號應該是英文狀態的分號,你寫的中文的,VS直接就報錯了,
2020-07-01
?Console.Write("有");和Console.Write("沒有7的整倍數");
后面的分號應該是英文狀態輸入;