請幫忙看看
using System;
using System.Collections.Generic;
using System.Text;
namespace Test
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? //聲明整型數組,保存一組整數
? ? ? ? ? ? int[] num = new int[] { 3,34,43,2,11,19,30,55,20};
? ? ? ? ? ? //請完善代碼,判斷數組中有沒有7的整倍數
? ? ? ? ? ? bool has7 = false;
? ? ? ? ? ? for(int i=0;i<num.length;i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if(num[i] %7==0)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? has7 = true;
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? if(has7)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? Console.Write("有7的整數倍");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ?Console.Write("沒有7的整數倍");??
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? }
}
2020-08-13
把兩行打印寫在for循環外面就行