哈工大机考:字符串内排序

时间限制:1秒 空间限制:32768K

题目描述

输入一个字符串,长度小于等于200,然后将输出按字符顺序升序排序后的字符串。
输入描述:
测试数据有多组,输入字符串。


输出描述:
对于每组输入,输出处理后的结果。

输入例子:
bacd

输出例子:
abcd

写个cmp函数就行
代码:
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;

int cmp(char a,char b){
   return a<b;
}

int main(){
   char a[210];
   cin>>a;
   sort(a,a+strlen(a),cmp);
   cout<<a<<endl;
   return 0;
}
原文地址:https://www.cnblogs.com/mlgjb/p/6908799.html