《算法筆記》4.1算法初步 排序 D 字符串排序

D 字符串排序

題目描述

輸入一個字符串,長度小於等於200,然後將輸出按字符順序升序排序後的字符串。

輸入

測試數據有多組,輸入字符串。

輸出

對於每組輸入,輸出處理後的結果。

樣例輸入

tianqin

樣例輸出

aiinnqt

提示

注意輸入的字符串中可能有空格。

#include <iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
using namespace std;


int main(int argc, char *argv[]) {
	char str[200];
	while(gets(str))  
	{
		sort(str, str + strlen(str));
		cout<<str<<endl; 
	}    

	return 0;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章