输入一个字符串,对该字符串进行逆序,输出逆序后的字符串。
输入格式:
输入在一行中给出一个不超过
80个字符长度的、以回车结束的非空字符串。
输出格式:
在一行中输出逆序后的字符串。
输入样例1:
Hello World
!
输出样例1:
!dlroW olleH
答案代码块
#include <stdio.h>
int main(){
char s
[80];
int cnt
=0,i
;
for(i
=0;s
[i
-1]!='\n';i
++){
s
[i
]=getchar();
cnt
=i
;
}
for(i
=cnt
-1;i
>=0;i
--){
printf("%c",s
[i
]);
}
return 0;
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-27128.html