string[] name = {"吴松","钱东宇","伏晨","陈陆","周蕊","林日鹏","何昆","关欣"}; int[] score= {90,65,88,70,46,81,100,68}; int temp = score[0]; for (int i = 0;i < 8;i++) { int sum = sum + score[i]; } int avg = sum/8; for (int i = 0;i < 8;i++) { if(score[i] > avg) { string name1 = name1 + " " + name[i]; } } { Console.WriteLine("平均分是{0},高于平均分的有{1}",avg,name1); }
1 回答
冰封一切1
TA贡献25条经验 获得超14个赞
恕我菜鸟比较笨,我想先问下int sum = sum + score[i];,这种格式对吗?而且还是在for循环里定义的,定义完没初始化就直接拿去用,而且需要每次循环定义一次num嘛?还有for里面定义的可以在for循环的外面使用嘛???,下面name也类似
- 1 回答
- 0 关注
- 799 浏览
添加回答
举报
0/150
提交
取消