天勤OJ 题目1220: 字符串处理

题目描述

输入任意4 个字符,并按反序输出。

 

输入

输入第一行表示测试样例个数m,接下来m行每行一个字符串。

 

输出

输出m行,分别对应输入字符串的反序。

 

样例输入
2
abcd
eerd
 

样例输出
dcba
dree
 
/*********************************
*   日期:2013-2-12
*   作者:SJF0115
*   题号: 天勤OJ 题目1220: 字符串处理
*   来源:http://acmclub.com/problem.php?id=1220
*   结果:AC
*   来源:2012年中国科技大学计算机研究生机试真题
*   总结:
**********************************/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main() {
    int n,i,j;
	char str[5];
    while (scanf("%d", &n) != EOF){
		for(i = 0;i < n;i++){
			scanf("%s",str);
			for(j = strlen(str)-1;j >= 0;j--){
				//printf("%c",str[j]);
				putchar(str[j]);
			}
			printf("\n");
		}
    }
    return 0;
}


你可能感兴趣的:(中国科技大学)