游客 Signup | Login
中文 | En

1837 - 课后习题7.2

通过次数

0

提交次数

0

Time Limit : 1 秒 Memory Limit : 128 MB

用选择法对10个整数从小到大排序。

Input

10个整数

Output

排序好的10个整数

Examples

Input Format

4 85  3 234 45 345 345 122 30 12

Output Format

3
4
12
30
45
85
122
234
345
345

Solution C

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

Solution C++

#include<bits/stdc++.h>
using namespace std;
long long a[1000000];
int main()
{
	for(int i=1;i<=10;i++)
		cin>>a[i];
	sort(a+1,a+11);
	for(int i=1;i<=10;i++)
		cout<<a[i]<<"\n";
		
    return 0;
}