1 题目大意:对于输入的字符串逆序排序后输出,空格排在最前面。不能使用既有排序算法,如sort。
#include<iostream>
#include<vector>
#include<string>
using namespace std;
void swap(string & a, string & b)
{
string tmp = a;
a = b;
b = tmp;
}
void Qsort(vector<string> & seq, int beg, int end)
{
string tmp = seq[beg];
if (beg >= end)
{
return;
}
int i = beg, j = end;
while (i != j)
{
while (j > i && seq[j] >= tmp)
{
j--;
}
swap(seq[i], seq[j]);
while (j > i && seq[i] <= tmp)
{
i++;
}
swap(seq[i], seq[j]);
}
Qsort(seq, beg, i - 1);
Qsort(seq, i + 1, end);
}
int main()
{
string in{};
cin >> in;
vector<string> seq{};
string tmp{};
for (int i = 0; i < in.size(); i++)
{
if (in