码迷,mamicode.com
首页 > 编程语言 > 详细

hdu2000 ASCII码排序【C++】

时间:2018-07-07 14:29:30      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:mit   ascii码   sample   java   ++   顺序   The   ali   namespace   

ASCII码排序

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 206054    Accepted Submission(s): 82273


Problem Description
输入三个字符后,按各字符的ASCII码从小到大的顺序输出这三个字符。
 

 

Input
输入数据有多组,每组占一行,有三个字符组成,之间无空格。
 

 

Output
对于每组输入数据,输出一行,字符中间用一个空格分开。
 

 

Sample Input
qwe asd zxc
 

 

Sample Output
e q w a d s c x z
 1 #include<iostream>
 2 #include<cstring>
 3 #include<algorithm>
 4 using namespace std;
 5 int main()
 6 {
 7     string s("");
 8     char a[10];
 9     while(getline(cin,s))
10     {
11         strcpy(a,s.c_str());
12         sort(a,a+3);
13         for(int i = 0;i < 3;++i)
14         {
15             if(i < 2)
16             {
17                 cout << a[i] << " " ;//不知道为什么不能cout << a[i] + " " ;
18             }
19             else
20             {
21                 cout << a[i] << endl;
22             }
23 
24         }
25     }
26     return 0;
27 }

 

hdu2000 ASCII码排序【C++】

标签:mit   ascii码   sample   java   ++   顺序   The   ali   namespace   

原文地址:https://www.cnblogs.com/knmxx/p/9277091.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!