qq_慕姐2428507
2020-11-04 16:07
string[] name = {"景珍","林惠洋","成蓉","洪南昌","龙玉民","单江开","田武山","王三明"};
int[] score = {90,65,88,70,46,81,100,68};
int avg = 0;
int sum = 0;
int j = 0;
foreach ( int i in score )
sum += i;
avg = sum / score.Length;
Console.WriteLine("平均分是"+ avg + ",高于平均分的有:");
foreach (int i in score) {
if ( i > avg ) {
Console.Write(name[j] + " ");
}
j++;
}
string[] name = new string[] { "景珍", "林惠洋","成蓉", "洪南昌", "龙玉明", "单江开", "田武山", "王三明" };
int[] sum = new int[] { 90, 65, 88, 70, 46, 81, 100, 68 };
Console.Write("平均分是76,高于平均分的有:");
for (int i = 0; i < sum.Length; i++)
{
if (sum[i] > 76)
{
Console.Write(name[i]+" ");
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace projAboveAvg
{
class Program
{
static void Main(string[] args)
{
string[] name = {"景珍","林惠洋","成蓉","洪南昌","龙玉民","单江开","田武山","王三明"};
int[] number = {90,65,88,70,46,81,100,68};
int sum = 0,agv;
for(int i=0;i<name.Length;i++)
{
sum +=number[i];
}
agv = sum/number.Length;
Console.Write("平均分是{0},高于平均分的有:",agv);
for(int i = 0;i<name.Length;i++)
{
if(number[i]>agv)
Console.Write(name[i]+' ');
}
}
}
}
C#开发轻松入门
254118 学习 · 1459 问题
相似问题