換個寫法,隨便寫寫
?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++;
? ? ? ? ? ? }
2021-08-03
? ? ? ? ? ? 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]+" ");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
2020-11-06
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]+' ');
? ? ? ? ? ? }
? ? ? ? }
? ? }
}