牛客网计算机考研复试-KY5-反序输出

题目链接:点这里


题目描述:
输入任意4个字符(如:abcd), 并按反序输出(如:dcba)


思路:
字符串逆序输出


代码:

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

int main(){
    string s;
    while(cin >> s){
        for(int i=s.length()-1;i>=0;i--)
            cout << s[i];
        cout << endl;
    }
    return 0;
}
posted @ 2021-01-16 12:09  吐司奶猫荷包蛋  阅读(110)  评论(0编辑  收藏  举报