課程
/后端開發(fā)
/C#
/C#開發(fā)輕松入門
幫幫看看代碼問題在哪?謝謝
2020-08-13
源自:C#開發(fā)輕松入門 5-8
正在回答
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};
? ? ? ? ? ? foreach(int x in num)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if(x%7==0)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? Console.Write("有7的整倍數(shù)");
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? Console.Write("沒有7的整倍數(shù)");
? ? ? ? ? ? }//請完善代碼,判斷數(shù)組中有沒有7的整倍數(shù)
? ? ? ? ? ??
? ? ? ? }
? ? }
}//我覺得還是這個簡單點
在 Console.Write 下面加上 break; 執(zhí)行一次 跳出就 ok了
?if(has7)
? ? ? ? ? ? ? ? ? ? Console.Write("有7的整數(shù)倍");
? ? ? ? ? ? ? ? ? ?Console.Write("沒有7的整數(shù)倍");??
這段代碼需要放在for循環(huán)之外;
放在循環(huán)里面,每次校驗時都會執(zhí)行,而我們只需要執(zhí)行一次
? ? ? ? ? ? //請完善代碼,判斷數(shù)組中有沒有7的整倍數(shù)
? ? ? ? ? ? bool has7 = false;
? ? ? ? ? ? for(int i=0;i<num.length;i++)
? ? ? ? ? ? ? ? if(num[i] %7==0)
? ? ? ? ? ? ? ? ? ? has7 = true;
? ? ? ? ? ? ? ? if(has7)
? ? ? ? ? ? }
}
舉報
本門課程是C#語言的入門教程,將帶你輕松入門.NET開發(fā)
1 回答點進去求解
1 回答求助???
6 回答請大神指點
2 回答請大佬解惑!
2 回答求助,這個哪錯了
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2021-05-07
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};
? ? ? ? ? ? foreach(int x in num)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if(x%7==0)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? Console.Write("有7的整倍數(shù)");
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? Console.Write("沒有7的整倍數(shù)");
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }//請完善代碼,判斷數(shù)組中有沒有7的整倍數(shù)
? ? ? ? ? ??
? ? ? ? }
? ? }
}//我覺得還是這個簡單點
2021-05-07
在 Console.Write 下面加上 break; 執(zhí)行一次 跳出就 ok了
2020-11-04
?if(has7)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? Console.Write("有7的整數(shù)倍");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ?Console.Write("沒有7的整數(shù)倍");??
? ? ? ? ? ? ? ? }
這段代碼需要放在for循環(huán)之外;
放在循環(huán)里面,每次校驗時都會執(zhí)行,而我們只需要執(zhí)行一次
2020-08-13
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};
? ? ? ? ? ? //請完善代碼,判斷數(shù)組中有沒有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("沒有7的整數(shù)倍");??
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? }
}