#include<iostream> #include<stdlib.h> using namespace std; int main() { int a[11]; int i, j, t; cout<<"input 10 nummbers:"<<endl; for(i=1;i<11;i++) { cin>>a[i]; } cout<<endl; for(j=1;j<11;j++) { for(i=1;i<=10-j;i++) { if(a[i]>a[i+1]) { t = a[i]; a[i] = a[i+1]; a[i+1] = t; } } } cout<<"the sorted nummbers:"<<endl; for(i=1;i<11;i++) { cout<<a[i]<<" "; } cout<<endl; system("pause"); return 0; }
时间: 2024-11-11 11:21:12