2 回答

TA貢獻(xiàn)2條經(jīng)驗(yàn) 獲得超0個(gè)贊
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
? ? 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ù)組中有沒有7的整倍數(shù)
? ? ? ? ? ? bool hasNub = false;
? ? ? ? ? ? for (int i = 0; i < num.Length; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (num[i] % 7 == 0)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? hasNub = true;
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? continue;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? if (hasNub)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? Console.WriteLine("有7的整數(shù)倍");
? ? ? ? ? ? }
? ? ? ? ? ? else
? ? ? ? ? ? {
? ? ? ? ? ? ? ? Console.WriteLine("沒有7的整數(shù)倍");
? ? ? ? ? ? }
? ? ? ? }
? ? }
}
- 2 回答
- 0 關(guān)注
- 2588 瀏覽
添加回答
舉報(bào)