题目描述
输入一个字符串,长度小于等于200,然后将数组逆置输出。
输入
测试数据有多组,每组输入一个字符串。
输出
对于每组输入,请输出逆置后的结果。
样例输入 Copy
tianqin
样例输出 Copy
niqnait
提示
注意输入的字符串可能会有空格。
代码
初出茅庐,请多指教!
#include<stdio.h>
int main(){
char a[210];
while(gets(a)!=NULL){
char stack[210]="";
int top=-1;
int i;
for(i=0;a[i]!='\0';i++){
stack[++top]=a[i];
}
while(top!=-1){
printf("%c",stack[top--]);
}
printf("\n");
}
return 0;
}