運行失敗,求問哪里錯了?
sing System;
using System.Collections.Generic;
using System.Text;
namespace projAboveAvg
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? int[]score=new int[]{90,65,88,70,46,81,100,68};
? ? ? ? ? ? string[]name=new string[]{"景珍","林惠洋","成蓉","洪南昌","龍玉民","單江開","田武山","王三明"};
? ? ? ? ? ? int sum=0,avg=0;
? ? ? ? ? ??
? ? ? ? ? ? for(int i=0,i<score.Length;i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? sum+=score[i];
? ? ? ? ? ? }
? ? ? ? ? ? avg=sum/score.Length;
? ? ? ? ? ? ? Console.WriteLine("平均分是{0},高于平均分的有:",avg);
? ? ? ? ? ? for(i=0;i<score.Length;i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if(score[i]>avg)
? ? ? ? ? ? ? ? Console.WriteLine(name[i]+" ");
? ? ? ? ? ? ? ?
? ? ? ? ? ? }
? ? ? ? ? ?
? ? ? ? ? ??
? ? ? ? }
? ? }
}
2023-08-24
?{
? ? ? ? ? ? int[] score = new int[] { 90, 65, 88, 70, 46, 81, 100, 68 };
? ? ? ? ? ? string[] name = new string[] { "景珍", "林惠洋", "成蓉", "洪南昌", "龍玉民", "單江開", "田武山", "王三明" };
? ? ? ? ? ? int sum = 0, avg = 0;
? ? ? ? ? ? for (int i = 0; i< score.Length; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? sum += score[i];
? ? ? ? ? ? }
? ? ? ? ? ? avg = sum / score.Length;
? ? ? ? ? ? Console.WriteLine("平均分是{0},高于平均分的有:", avg);
? ? ? ? ? ? for (int i = 0; i < score.Length; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (score[i] > avg)
? ? ? ? ? ? ? ? ? ? Console.WriteLine(name[i] + " ");
? ? ? ? ? ? }
}
這樣就沒問題了
2023-06-28
? string[] name=new string[8]{"景珍","林惠洋","成蓉","洪南昌","尤玉民","單江開","田武山","王三明"};
? ? ? ? ? ? int[] score = new int[8]{90,65,88,70,46,81,100,68};
? ? ? ? ? ? int sum =0,avg=0;
? ? ? ? ? ? for(int i=0;i<score.Length;i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? sum+=score[i];
? ? ? ? ? ? }
? ? ? ? ? ? avg=sum/score.Length;
? ? ? ? ? ? Console.WriteLine("平均分:{0}",avg);
? ? ? ? ? ? for(int i=0;i<score.Length;i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if(score[i]>avg)
? ? ? ? ? ? ? ? ? ? Console.Write("{0}"+" ",name[i]);
? ? ? ? ? ? }
2023-03-25
?for(int i=0,i<score.Length;i++) // 這句錯了,int i=0; 分號不是逗號
Console.WriteLine(name[i]+" "); // 輸出要求姓名在同一行上,WriteLine輸出一個名字后會換行
2023-01-07
using System;
using System.Collections.Generic;
using System.Text;
namespace projAboveAvg
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? int[] score = new int[] { 90, 65, 88, 70, 46, 81, 100, 68 };
? ? ? ? ? ? string[] name = new string[] { "景珍", "林惠洋", "成蓉", "洪南昌", "龍玉民", "單江開", "田武山", "王三明" };
? ? ? ? ? ? int sum = 0, avg = 0;
? ? ? ? ? ? for (int i = 0; i < score.Length; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? sum += score[i];
? ? ? ? ? ? }
? ? ? ? ? ? avg = sum / score.Length;
? ? ? ? ? ? Console.WriteLine("平均分是{0},高于平均分的有:", avg);
? ? ? ? ? ? for (int i = 0; i < score.Length; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (score[i] > avg)
? ? ? ? ? ? ? ? ? ? Console.Write(name[i] + " ");
? ? ? ? ? ? }
? ? ? ? }
? ? }
}
2023-01-05
第一行using? 少了個u? ?
avg = sum / score.Length? 不能這樣寫,要直接寫8
2022-12-21
我猜是?平均分是{0},? 這段最后的這個逗號沒有用中文逗號