【C#课堂练习】数组冒泡排序法排序
本文最后更新于 1530 天前,其中的信息可能已经有所发展或是发生改变。

Program.cs

[sourcecode language=”c”]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double[] height = new double[10];
double sum=0,avger,her;
for (int i = 0; i <= 9; i++)
{
Console.Write("请输入一个数:");
height[i] = double.Parse(Console.ReadLine());
sum = sum + height[i];
}
for (int i = 9; i >= 1; i–)
{
for (int b = 0; b <= i-1; b++)
{
if (height[i] < height[b])
{
her = height[i];
height[i] = height[b];
height[b] = her;
}
}
}
avger=sum/10;
Console.WriteLine("平均值为{0}", avger);
for (int i = 0; i < height.Length; i++)
{
Console.Write("{0} ", height[i]);
}
Console.ReadKey();
}
}
}

[/sourcecode]

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇