hdu oj 2000

来源:互联网 发布:ccn是什么网络 编辑:程序博客网 时间:2024/04/29 17:25

  ASCII码排序

Problem Description
输入三个字符后,按各字符的ASCII码从小到大的顺序输出这三个字符。
 Input
输入数据有多组,每组占一行,有三个字符组成,之间无空格。
 Output
对于每组输入数据,输出一行,字符中间用一个空格分开。
 Sample Input
qweasdzxc
 Sample Output
e q wa d sc x z

my code:

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  char r[4];
  while(cin>>r){
   std::sort(&r[0],&r[3]);
   cout<<r[0]<<' '<<r[1]<<' '<<r[2]<<endl;
}
return 0;
}

原创粉丝点击