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