#include <iostream>
using namespace std; #define N 10 void main() { int a[N]; int i,j,t; cout<<"input "<<N<<" number:"<<endl; for(i=0;i<N;i++) cin>>a[i]; for(j=0;j<N-1;j++) for (i=0;i<N-j-1;i++) if(a[i]>a[i+1]) { t=a[i]; a[i]=a[i+1]; a[i+1]=t; } cout<<"the sorted numbers is:"<<endl; for(i=0;i<N;i++) cout<<a[i]<<" "; cout<<endl; } |
|