課程
/后端開發(fā)
/C#
/C#開發(fā)輕松入門
如果實(shí)戰(zhàn)中名字和分?jǐn)?shù)在數(shù)組中的位置并沒有一一對應(yīng)時(shí)怎么辦呢?
2024-02-01
源自:C#開發(fā)輕松入門 6-2
正在回答
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);
? ? ? ? ? ? ? ? if(int.Parse(arr[i,1])>avg){
? ? ? ? ? ? ? ? ? ? Console.Write(arr[i,0]+" ");
? ? ? ? ? ? ? ? }
? ? ? ? }
? ? }
}
舉報(bào)
本門課程是C#語言的入門教程,將帶你輕松入門.NET開發(fā)
6 回答如何在分?jǐn)?shù)數(shù)組中查找最高分
2 回答數(shù)組元素牽引和名字輸出
1 回答老師在嗎?用二維數(shù)組還是一維數(shù)組效率比較高呢?我現(xiàn)在用的是二維數(shù)組,代碼如下
3 回答請問在數(shù)組中查找最高值是怎么計(jì)算的?
3 回答這道題如果用二維數(shù)組的話該怎么作?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
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]+" ");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? }
}