共享答案。。。
using System;
using System.Collections.Generic;
using System.Text;
namespace projGetMaxScore
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? string []names ={"吳松","錢東宇","伏晨","陳陸","周蕊","林日鵬","何昆","關(guān)欣"};
? ? ? ? ? ? int []score={89,90,98,56,60,91,93,85};
? ? ? ? ? ? for (int i=0;i<score.Length;i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if(score[0]<score[i])
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? score[0]=score[i];
? ? ? ? ? ? ? ? ? ? names[0]=names[i];
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? Console.WriteLine("分?jǐn)?shù)最高的是{0},分?jǐn)?shù)是{1}",names[0],score[0]);
? ? ? ? }
? ? }
}
2023-05-10
using System;
using System.Collections.Generic;
using System.Text;
namespace projGetMaxScore
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? string[,]s={{"吳松","89"},{"錢東宇","90"},{"伏晨","98"},{"陳陸","56"},{"周蕊","60"},{"林日鵬","91"},{"何昆","93"},{"關(guān)欣","85"}}? ? ;
? ? ? ? ? ?for (int y = 0; y < s.GetLength(0)-1; y++)
? ? ? ? ? ? ? ? {??
? ? ? ? ? ? ? ? ?if (Convert.ToInt32(s[0, 1]) < Convert.ToInt32(s[y + 1, 1]))
? ? ? ? ? ? ? ? ? ?{
? ? ? ? ? ? ? ? ? ? ?s[0,1]=s[y+1,1];
? ? ? ? ? ? ? ? ? ? ?s[0,0]=s[y+1,0];
? ? ? ? ? ? ? ? ? ? // Console.WriteLine("{0},{1}", s[0,0],s[0,1]);
? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ?}?
? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? }
? ? ? Console.WriteLine("分?jǐn)?shù)最高的是{0},分?jǐn)?shù)是{1}", s[0,0],s[0,1]);
? ? ? ? }
? ? }
}
2023-05-10
using System;
using System.Collections.Generic;
using System.Text;
namespace projAboveAvg
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? string[,]s ={{"景珍","90"},{"林惠洋","65"},{"成蓉","88"},{"洪南昌","70"},{"龍玉民","46"},{"單江開","81"},{"田武山","100"},{"王三明","68"}};??
? ? ? ? ? int agv=0;
? ? ? ? ? int sum=0;
? ? ? ? ? for(int x =0 ;x<s.GetLength(0);x++)
? ? ? ? ? ?{
? ? ? ? ? ? sum = sum + Convert.ToInt32(s[x, 1]);
? ? ? ? ? ?}
? ? ? ? ? ?agv=sum/s.GetLength(0);
? ? ? ? ? ?Console.WriteLine("平均分是"+agv+",高于平均分的有:");
? ? ? ? ? ? for(int y=0;y<s.GetLength(0)-1;y++)
? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? if(Convert.ToInt32(s[y,1])>agv)
? ? ? ? ? ? ? ? Console.Write("{0} ",s[y,0]);
? ? ? ? ? ? ??
? ? ? ? ? ? ? }
? ? ? ? ? ? ??
? ? ? ? }
? ? }
}