1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 |
#include <iostream> using
namespace
std; void
sort( int
b[], int
n) { int
t; for ( int
i=1;i<n;i++) for ( int
j=0;j<n-i;j++) { if (b[j]>=b[j+1]) { t=b[j+1]; b[j+1]=b[j]; b[j]=t; } } } int
main() { int
a[202],n,temp,i,j; while (cin>>n) { for (i=0;i<n;i++) cin>>a[i]; /* for(i=1;i<n;i++) for(j=n-1;j>=i;j--) if(a[j]<=a[j-1]) { temp=a[j]; a[j]=a[j-1]; a[j-1]=temp; } */ sort(a,n); for (i=0;i<n;i++) cout<<a[i]<< " " ; cout<<endl; } return
0; } |
声明:本代码仅供参考。
原文:http://www.cnblogs.com/MonkeyAC/p/3525918.html