運行正確,輸出錯誤。但是沒有錯啊。。。。dalao能幫我看看么
?int[] score = new int[]{90,65,88,70,46,81,100,68};
? ? ? ? ? ? string[] name = new string[]{"景珍","林惠洋","成蓉","洪南昌","龍玉良","單江開","田武山","王三明"};
? ? ? ? ? ? int sum=0,avg;
? ? ? ? ? ? int m;
? ? ? ? ? ??
? ? ? ? ? ? for(int i=0;i<score.Length;i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? sum += score[i];
? ? ? ? ? ? }
? ? ? ? ? ? avg = sum / score.Length;
? ? ? ? ? ? Console.WriteLine("平均分是" + avg + ",高于平均分的有:");
? ? ? ? ? ? for(int i=0;i<score.Length;i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if(score[i] > avg)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? m = i;
? ? ? ? ? ? ? ? ? ? Console.Write(name[m] + " ");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
以上是我的代碼
2018-09-19
輸出中的逗號和冒號必須是中文符號
2018-09-18
以下是我的代碼,樓主連注釋都沒有,實在懶得看
static void Main(string[] args)
??????? {
??????????? string []name = new string[]{"景珍","林惠洋","成蓉","洪南昌","龍玉民","單江開","田武山","王三明"};
??????????? double []score =new double[]{90,65,88,70,46,81,100,68};
???????????
??????????? double avg =0;
??????????? double sum = 0; // 聲明各種變量;
??????????? for (int i =0;i<score.Length;i++)
??????????? {
??????????????? sum+=score[i];
??????????? }??? // 總分;
??????????? avg = sum/score.Length;
??????????? Console.Write("平均分是"+avg+",高于平均分的有:");//平均分;
??????????? //接下來是求高于平均分
??????????? for(int j = 0; j<score.Length;j++)
??????????? {
??????????????? if(score[j]>avg)
??????????????? {
???????????????????
???????????????? Console.Write( name[j]+" " );
??????????????? }
??????????? }
2018-09-11
在第二個for循環(huán)中間的if條件句后面加else
{
continue;
}
2018-09-09
輸出第一行的逗號用中文的逗號,下面輸出名字可以直接用Console.Write(name[i]+" ");