更新时间:2015-10-02 11:52:07浏览次数:1+次
#include "stdafx.h"
#include<iostream>
#include<vector>
#include<algorithm>
#define charSize 128
using namespace std;
void Output(char ch)
{
cout << ch << " ";
}
void main()
{
char String[charSize];
vector<char>charVector;
cout << "please input:" << endl;
cin >> String;
for (int i = 0; String[i] != '\0'; i++) { charVector.push_back(String[i]); }
cout << "输出未排序前字符串:";
for_each(charVector.begin(), charVector.end(), Output);
cout << endl << "输出排序后字符串:";
sort(charVector.begin(), charVector.end()); //排序
for_each(charVector.begin(), charVector.end(), Output);
cout << endl;
}
相关资讯