qq_一把刷子_03186227
2016-04-21 19:38
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]+"");
}
}
}
}
这个可以运行的呀,编译器上通过了,没问题啊
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] + " ");
}
}
}
}
第一个for循环,你写成fot
C#开发轻松入门
254118 学习 · 1459 问题
相似问题