陌上看花人

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
 1 #include <iostream>
 2 #include <string.h>
 3 using namespace std;
 4 int main()
 5 {
 6     char a[100];
 7     int i,j,n,temp;
 8     cout<<"input numbers:"<<endl;
 9     gets(a);
10     n=strlen(a); 
11     for(j=0;j<n-1;j++)
12         for(i=0;i<n-j-1;i++)
13             if(a[i]>a[i+1])
14                 {
15                     temp=a[i];
16                     a[i]=a[i+1];
17                     a[i+1]=temp;
18                 }
19     cout<<"from small to large output the numbers :"<<endl;
20     for(i=0;i<n;i++)
21     cout<<a[i]<<" ";
22     
23     return 0;
24  }

 

posted on 2016-11-12 13:24  啊咿呀哈  阅读(430)  评论(0编辑  收藏  举报