感覺代碼沒問題 為何運行不過去
namespace Test
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? //聲明整型數(shù)組,保存一組整數(shù)
? ? ? ? ? ? int[] num = new int[] { 3,34,43,2,11,19,30,55,20};
? ? ? ? ? ? bool has7=false;
? ? ? ? ? ? foreach (int x in num)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if(x % 7== 0)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ?has7=true;
? ? ? ? ? ? ? ? ? ?break;
? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? if(has7)
? ? ? ? ? console.Writeline("有7的整倍數(shù)");
? ? ? ? ? else
? ? ? ? ? cinsole.Writeline("沒有7的整倍數(shù)");
? ? ? ? }
? ? }
}
2019-04-21
非常感謝
2019-04-19
有兩個問題:
(1)bool has7=false;和cinsole.Writeline("沒有7的整倍數(shù)");的分號為中文輸入,要改成英文狀態(tài);
(2)console.Writeline("有7的整倍數(shù)");和 cinsole.Writeline("沒有7的整倍數(shù)");中存在拼寫錯誤,正確的是Console.WriteLine;C#中區(qū)分大小寫。