1. 程式人生 > >哈工大機考:數組逆置

哈工大機考:數組逆置

end std gin () 數據 log ostream margin 哈工大

時間限制:1秒 空間限制:32768K

題目描述

輸入一個字符串,長度小於等於200,然後將數組逆置輸出。
輸入描述:
測試數據有多組,每組輸入一個字符串。


輸出描述:
對於每組輸入,請輸出逆置後的結果。

輸入例子:
hdssg

輸出例子:
gssdh

代碼:
#include <iostream>
#include  <stdio.h>
#include <string.h>
using namespace std;

int main(){
   char a[210];
    while(gets(a)){
     for(int i=strlen(a)-1
;i>=0;i--){ cout<<a[i]; } cout<<endl; } return 0; }

哈工大機考:數組逆置