1055.数组逆置

题目描述:
输入一个字符串,长度小于等于200,然后将数组逆置输出。
输入:
测试数据有多组,每组输入一个字符串。
输出:
对于每组输入,请输出逆置后的结果。

样例输入:
hdssg
样例输出:
gssdh

#include<iostream>
#include<cstring>
using namespace std;

int main(){
    int i; 
    char a[201];
    while(gets(a)){
        int len=strlen(a);
        for(i=0;i<len/2;i++){
            char temp=a[i];
            a[i]=a[len-i-1];
            a[len-i-1]=temp;
        }
        for(i=0;i<len;i++){
            cout<<a[i];
        }
        cout<<endl;
    }
    return 0;
}

 

posted @ 2018-10-01 17:55  bernieloveslife  阅读(197)  评论(0编辑  收藏  举报