麻煩問一下,這段代碼哪里錯了,謝謝
using System;
using System.Collections.Generic;
using System.Text;
namespace projAboveAvg
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? string[] name=new string{"景珍","林惠洋","成蓉","洪南昌","龍玉民","單江開","田武山","王三明"};
? ? ? ? ? ? int[] number=new int{90,65,88,70,46,81,100,68};
? ? ? ? ? ? int sum=0;
? ? ? ? ? ? int avg=0;
? ? ? ? ? ??
? ? ? ? ? ? fot(int i=0;i<number.Length;i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? sum+=number[i];
? ? ? ? ? ? }
? ? ? ? ? ? avg=sum/(number.Length);
? ? ? ? ? ??
? ? ? ? ? ? Console.WriteLine("平均分是{0},高于平均分的有:",avg);
? ? ? ? ? ??
? ? ? ? ? ? for(int a=0;a<number.Length;a++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if(avg>=number[a])
? ? ? ? ? ? ? ? Console.Write(name[a]+"");
? ? ? ? ? ? }
? ? ? ? }
? ? }
}
2016-04-22
這個可以運行的呀,編譯器上通過了,沒問題啊
2016-07-19
namespace projAboveAvg
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? string[] name = new string[] { "景珍", "林惠洋", "成蓉", "洪南昌", "龍玉民", "單江開", "田武山", "王三明" };
? ? ? ? ? ? int[] number = new int[] { 90, 65, 88, 70, 46, 81, 100, 68 };
? ? ? ? ? ? int sum = 0;
? ? ? ? ? ? int avg = 0;
? ? ? ? ? ? for(int i = 0; i < number.Length; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? sum += number[i];
? ? ? ? ? ? }
? ? ? ? ? ? avg = sum / (number.Length);
? ? ? ? ? ? Console.WriteLine("平均分是{0},高于平均分的有:", avg);
? ? ? ? ? ? for (int a = 0; a < number.Length; a++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (avg <= number[a])
? ? ? ? ? ? ? ? ? ? Console.Write(name[a] + " ");
? ? ? ? ? ? }
? ? ? ? }
? ? }
}
2016-05-11
第一個for循環(huán),你寫成fot