游客 Signup | Login
中文 | En

2248 - a1007

编程,将一个长度为10的数组中的数据按从小到大排序,并输出排序结果.

Input


Output


Examples

Input

10
9
8
7
6
5
4
3
2
1

Output

1
2
3
4
5
6
7
8
9
10

Solution C

#include<stdio.h>
int main()
{
	int a[10],i,j,t;
	for(i=0;i<10;i++)
		scanf("%d",&a[i]);
	for(i=0;i<9;i++)
		for(j=0;j<9;j++)
			if(a[j]>a[j+1])
			{
				t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;
			}
	for(i=0;i<10;i++)
		printf("%d\n",a[i]);
}

Solution C++

#include<iostream>
#include<cstdio>
#include<iostream>
#include<cmath>

using namespace std;

int main(){
    int a[15];
    for(int i=0;i<10;i++)
        cin>>a[i];
    for(int i=0;i<9;i++)
        for(int j=0;j<9-i;j++)
            if(a[j] > a[j+1]){
                int temp = a[j];
                a[j] = a[j+1];
                a[j+1] = temp;
            }
    for(int i=0;i<10;i++)
        cout<<a[i]<<endl;
    return 0;
}

Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题