蓝桥杯 1093:字符逆序

题目描述

将一个字符串str的内容颠倒过来,并输出。str的长度不超过100个字符。

输入

输入包括一行。 第一行输入的字符串。

输出

输出转换好的逆序字符串。

样例输入

I am a student

样例输出

tneduts a ma I

代码:

#include <iostream>
#include<string>
using namespace std;
int main() {
    string str;

    getline(cin, str);

    for (int i = str.size()-1; i >= 0; i--) {//序号从0开始,到str.size()结束
        cout << str[i];
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_42082542/article/details/86762610