代碼有錯。
?bool has7 = false;
? ? ? ? ? ? foreach(int x in num)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if(x%7 == 0)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? has7 =true;
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? if (has7)
? ? ? ? ? ? {Console.WrtieLine("有7的整數倍");}
? ? ? ? ? ? else
? ? ? ? ? ? {Console.WrtieLine("沒有7的整數倍");}
這段代碼有錯,請幫我找找
2018-09-18
Console.WrtieLine 單詞拼錯了,WriteLine
2018-09-13
你用foreach,所以定義的x只能輸出,不能賦值
我用的for
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};
? ? ? ? ? ? //請完善代碼,判斷數組中有沒有7的整倍數
? ? ? ? ? ? bool x=false;
? ? ? ? ? ? for(int i =0;i<num.Length;i++){
? ? ? ? ? ? ? ?if(num[i]%7==0)
? ? ? ? ? ? ? ?{x=true;
? ? ? ? ? ? ? ?break;}
? ? ? ? ? ? ? ?
? ? ? ? ? ? }
? ? ? ? ? ? if(x)
? ? ? ? ? ? Console.WriteLine("you");
? ? ? ? ? ? else
? ? ? ? ? ? Console.WriteLine("mei you");
? ? ? ? ? ??
? ? ? ? }
? ? }
}
2018-04-04
Write ?Write