不改變數組
? ? ? ? ? ? string[,] t={{"吳松","錢東宇","伏晨","陳陸","周蕊","林日鵬","何昆","關欣"},{"89","90","98","56","60","91","93","85"}};
? ? ? ? ? ? int b=0,c=0;
? ? ? ? ? ? for(int a=0;a<t.GetLongLength(1);a++){
? ? ? ? ? ? ? ? if(Convert.ToInt32(t[1,a])>c){c=Convert.ToInt32(t[1,a]);
? ? ? ? ? ? ? ? b=a;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? Console.Write("分數最高的是{0},分數是{1}",t[0,b],t[1,b]);
2024-02-01
using System;
using System.Collections.Generic;
using System.Text;
namespace projAboveAvg
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? int avg = 0;
? ? ? ? ? ? int sum = 0;
? ? ? ? ? ? int[] scores=new int[8]{90,65,88,70,46,81,100,68};
? ? ? ? ? ? string[] names= new string[8]{"景珍","林惠祥","成蓉","洪南昌","龍玉民","單江開","田武山","王三明"};
? ? ? ? ? ? foreach(int x in scores){
? ? ? ? ? ? ? ? sum+=x;
? ? ? ? ? ? }
? ? ? ? ? ? avg=sum/(names.Length);
? ? ? ? ? ? Console.Write("平均分是{0},高于平均分的有:",avg);
? ? ? ? ? ? for(int i=0;i<scores.Length;i++){
? ? ? ? ? ? ? ? if(scores[i]>avg){
? ? ? ? ? ? ? ? ? ? Console.Write(names[i]);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ??
? ? ? ? ? ??
? ? ? ? }
? ? }
}