根据字典序进行排序,这里用到了sort是c++的用法,以前的代码,有大神指导下才用了sort,这里接触有点早。可以直接按数字把它当成asc码数字处理,所以排数字就行了。
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<algorithm>
using namespace std;
int main() {
char str[4];
while(scanf("%s",str)!=EOF) {
sort(str,str+3);
for(int i=0; i<3; i++) {
if(i==2)
printf("%c\n",str[i]);
if(i<2)
printf("%c ",str[i]);
}
}
return 0;
}