HDU 1062(水题)

来源:互联网 发布:大数据安全与隐私保护 编辑:程序博客网 时间:2024/06/03 09:27

题意:如题。

#include <cstdio>#include <string>#include <iostream>#include <algorithm>using namespace std;void deal(string& line, int start, int end){    end -= 1;    while (start < end)    {        line[start] ^= line[end] ^= line[start] ^= line[end];        start++, end--;    }}void result(string& line){    int start, end = 0;    bool flag = false;    while (1)    {        start = line.find_first_not_of(' ', end);        if (start == string::npos)            return;        end = line.find_first_of(' ', start);        if (end == string::npos)        {            flag = true;            end = line.length();        }        deal(line, start, end);        if (flag) return;    }}int main(){    int n;    cin >> n;    getchar();    string line;    while (n--)    {        getline(cin, line);        result(line);        cout << line << endl;    }    return 0;}


 

0 0
原创粉丝点击