這個代碼那里不對啊
?static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? //聲明整型數組,保存一組整數
? ? ? ? ? ? int[] num = new int[] { 3,34,43,2,11,19,30,55,20};
? ? ? ? ? ? bool has7=false;//請完善代碼,判斷數組中有沒有7的整倍數
? ? ? ? ? ? for(int i=0; i<num.Length;i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if(num%7==0)
? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? has7 = ture;
? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? if(has7)
? ? ? ? ? ? ? ? Console.WriteLine("有7的整倍數");
? ? ? ? ? ? else
? ? ? ? ? ? ? ? Console.WriteLine("沒有7的整倍數");
? ? ? ? }
2020-08-11
錯誤1:?if(num%7==0)? 改成? if (num[i] % 7 == 0)
錯誤2:?has7 =?ture;//? 改成? ?has7 =?ture;
2020-07-24
static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? //聲明整型數組,保存一組整數
? ? ? ? ? ? int[] num = new int[] { 3,34,43,2,11,19,30,55,20};
? ? ? ? ? ? bool has7=false;//請完善代碼,判斷數組中有沒有7的整倍數
? ? ? ? ? ? for(int i=0; i<num.Length;i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if(num%7==0)//num[i]%7==0
? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? has7 = ture;//是true
? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? if(has7)
? ? ? ? ? ? ? ? Console.WriteLine("有7的整倍數");
? ? ? ? ? ? else
? ? ? ? ? ? ? ? Console.WriteLine("沒有7的整倍數");
? ? ? ? }
看加粗的!
2020-07-24
重置代碼試一下