九度OJ 1055:数组逆置

题目地址:http://ac.jobdu.com/problem.php?id=1055

题目描述:

输入一个字符串,长度小于等于200,然后将数组逆置输出。

输入:

测试数据有多组,每组输入一个字符串。

输出:

对于每组输入,请输出逆置后的结果。

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

 

 1 #include<stdio.h>
 2 #include<string.h>
 3 #define N 201
 4 
 5 void main()
 6 {
 7     char str[N];
 8     int i,j=0;
 9     while(1){
10     if(!gets(str)) break;
11     i=strlen(str)-1;
12 
13     while(i>=0)   printf("%c",str[i--]);
14     printf("\n");
15     }
16 }
posted @ 2012-05-01 23:13  Bay  阅读(307)  评论(0)    收藏  举报