华为机试 字符串反转

题目描述

写出一个程序,接受一个字符串,然后输出该字符串反转后的字符串。例如:

输入描述:

输入N个字符

输出描述:

输出该字符串反转后的字符串


输入

abcd

输出

dcba



#include<iostream>
#include<string.h>

using namespace std;

int main(){
    string word;
    cin>>word;
    int len = word.length();
    for(int i=len-1;i>=0;i--){
        cout<<word[i];
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/JaminLin/p/9544271.html