using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{int []a=new int [10];//票数数组
int aa;//临时变量
//读入票数
Console.WriteLine("请输入前10强的票数");
for (int i = 0; i < 10;i++ ) {
Console.WriteLine("请输入第{0}强的票数", i + 1);
a[i]=int.Parse(Console.ReadLine ());//类型转换
}//开始排序-----使用冒泡排序
for (int i = 0; i < a.Length-1;i++ ) //控制比较多少轮
{//将最大的元素交换到最后
for (int j = 0; j < a.Length - 1 - i;j++ ) {
if (a[j]>a[j+1]){
//交换元素
aa = a[j];
a[j] = a[j + 1];
a[j+1]=aa;
}
}
}
//排序后输出
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载