如果實(shí)戰(zhàn)中名字和分?jǐn)?shù)在數(shù)組中的位置并沒(méi)有一一對(duì)應(yīng)時(shí)怎么辦呢?
如果實(shí)戰(zhàn)中名字和分?jǐn)?shù)在數(shù)組中的位置并沒(méi)有一一對(duì)應(yīng)時(shí)怎么辦呢?
如果實(shí)戰(zhàn)中名字和分?jǐn)?shù)在數(shù)組中的位置并沒(méi)有一一對(duì)應(yīng)時(shí)怎么辦呢?
2024-02-01
舉報(bào)
2024-04-10
using System;
using System.Collections.Generic;
using System.Text;
namespace projAboveAvg
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? string[,]arr={{"景珍","90"},{"林慧洋","65"},{"成蓉","88"},{"洪南昌","70"},{"龍玉民","46"},{"單江開","81"},{"田武山","100"},{"王三明","68"},};
? ? ? ? ? ? int sum=0;
? ? ? ? ? ? for(int i=0;i<arr.GetLength(0);i++){
? ? ? ? ? ? ? ? ?sum+=int.Parse(arr[i,1]);
? ? ? ? ? ? }
? ? ? ? ? ? int avg=sum/arr.GetLength(0);
? ? ? ? ? ? Console.Write("平均分是{0},高于平均分的有:",avg);
? ? ? ? ? ? for(int i=0;i<arr.GetLength(0);i++){
? ? ? ? ? ? ? ? if(int.Parse(arr[i,1])>avg){
? ? ? ? ? ? ? ? ? ? Console.Write(arr[i,0]+" ");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? }
}