题解 | 多组_带空格的字符串_T组形式

多组_带空格的字符串_T组形式

https://www.nowcoder.com/practice/cff28a28d7f54419a640a8bb19f4275f

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;

    while (t--) {
        int n;
        cin >> n;
        cin.ignore();           // 跳过换行
        string s;
        getline(cin, s);        // 读整行

        string result;
        for (char c : s) {
            if (c != ' ') {
                result += c;
            }
        }
        reverse(result.begin(), result.end());
        cout << result << '\n';
    }

    return 0;

}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

孙艹肘:校招不给三方直接让实习我都去了,,主打一个在学校呆着也是闲着,不如出来实习一下
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务