继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

用foreach 遍历数组中的每一个元素。

常宁3249220
关注TA
已关注
手记 1
粉丝 2
获赞 14

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 };
bool has7 = false;
foreach (int x in num)// 遍历num数组中的每一个元素
{
if (x % 7 == 0)
{
has7 = true;
break;
}
}
if (has7)
Console.Write("有7的整倍数");
else
Console.Write("没有7的整倍数");//请完善代码,判断数组中有没有7的整倍数

    }
}

}

打开App,阅读手记
3人推荐
发表评论
随时随地看视频慕课网APP