46 lines
871 B
C++
46 lines
871 B
C++
|
#include <iostream>
|
|||
|
#include <string>
|
|||
|
#include <vector>
|
|||
|
#include <algorithm>
|
|||
|
#include "split.h"
|
|||
|
|
|||
|
using std::cin;
|
|||
|
using std::cout;
|
|||
|
using std::endl;
|
|||
|
using std::string;
|
|||
|
using std::vector;
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|||
|
string reverseString(const string& s) {
|
|||
|
return string(s.rbegin(), s.rend());
|
|||
|
}
|
|||
|
|
|||
|
int main() {
|
|||
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>
|
|||
|
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>: ";
|
|||
|
string input;
|
|||
|
std::getline(cin, input);
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
|||
|
vector<string> words = split(input);
|
|||
|
|
|||
|
// <20><>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>з<EFBFBD>ת
|
|||
|
for (auto& word : words) {
|
|||
|
word = reverseString(word);
|
|||
|
}
|
|||
|
|
|||
|
// <20><><EFBFBD>շ<EFBFBD>ת<EFBFBD><D7AA><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
std::sort(words.begin(), words.end());
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5>ʣ<EFBFBD><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽһ<CABD><D2BB>
|
|||
|
for (size_t i = 0; i < words.size(); ++i) {
|
|||
|
if (i > 0) {
|
|||
|
cout << " "; // <20><><EFBFBD>ʼ<EFBFBD><CABC>ӿո<D3BF>
|
|||
|
}
|
|||
|
cout << words[i];
|
|||
|
}
|
|||
|
cout << endl;
|
|||
|
|
|||
|
return 0;
|
|||
|
}
|