課程
/后端開發(fā)
/C#
/C#開發(fā)輕松入門
在數(shù)組中查找最大值公式是怎么計算的?
2019-05-07
源自:C#開發(fā)輕松入門 6-1
正在回答
int[] nums = new int[] { 465, 464, 31, 897, 138, 281, 487 };//聲明一個數(shù)組
? ? ? ? ? ? Array.Sort(nums);//想省代碼量的話可以調(diào)用c#里自帶的類排序,這個是從小到大
? ? ? ? ? ? Console.WriteLine(nums[6]);//完了輸出最后一個,排完以后最后一個最大。。。
int[] i=new int[]{89,90,98,56,60,91,93,85};
? ? ? ? ? ? string[] s=new string[]{"吳松","錢東宇","伏晨","陳陸","周蕊","林日鵬","何昆","關(guān)欣"};
? ? ? ? ? ? string t = i.Max().ToString();
? ? ? ? ? ? int a = 0;
? ? ? ? ? ? for (a = 0; a <= i.Length; a++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (i.Max() == i[a])//數(shù)組可以直接用Max
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? Console.WriteLine(t+","+s[a]);
? ? ? ? ? ? Console.ReadKey();
int [] userArry = new int[]{1,2,3,4,5,6};
int maxV = userArry[0], fornt = 0;??????????? for (int len = 0; len < userArry.Length; len++)??????????? {??????????????? if (maxV < userArry[len])??????????????? {??????????????????? maxV = userArry[len];??????????????????? fornt = len;??????????????? }?????????????? ???????????? }Console.WriteLine("這個數(shù)組最大的元素是 "+maxV + "他的腳標(biāo)是 " + fornt);
舉報
本門課程是C#語言的入門教程,將帶你輕松入門.NET開發(fā)
6 回答如何在分?jǐn)?shù)數(shù)組中查找最高分
1 回答計算機計算問題
3 回答算法————查找
3 回答自定義數(shù)值常量為什么自動計算不上
2 回答這個從右向左計算,是怎么理解的
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2019-05-31
int[] nums = new int[] { 465, 464, 31, 897, 138, 281, 487 };//聲明一個數(shù)組
? ? ? ? ? ? Array.Sort(nums);//想省代碼量的話可以調(diào)用c#里自帶的類排序,這個是從小到大
? ? ? ? ? ? Console.WriteLine(nums[6]);//完了輸出最后一個,排完以后最后一個最大。。。
2019-05-20
int[] i=new int[]{89,90,98,56,60,91,93,85};
? ? ? ? ? ? string[] s=new string[]{"吳松","錢東宇","伏晨","陳陸","周蕊","林日鵬","何昆","關(guān)欣"};
? ? ? ? ? ? string t = i.Max().ToString();
? ? ? ? ? ? int a = 0;
? ? ? ? ? ? for (a = 0; a <= i.Length; a++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (i.Max() == i[a])//數(shù)組可以直接用Max
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? Console.WriteLine(t+","+s[a]);
? ? ? ? ? ? Console.ReadKey();
2019-05-10
int [] userArry = new int[]{1,2,3,4,5,6};
int maxV = userArry[0], fornt = 0;
??????????? for (int len = 0; len < userArry.Length; len++)
??????????? {
??????????????? if (maxV < userArry[len])
??????????????? {
??????????????????? maxV = userArry[len];
??????????????????? fornt = len;
??????????????? }?????????????? ?
??????????? }Console.WriteLine("這個數(shù)組最大的元素是 "+maxV + "他的腳標(biāo)是 " + fornt);