从键盘输入一个字符串,将其按逆序输出。
#include<stdio.h>
//注明字符串函数头文件
#include<string.h>
int main()
{
//定义字符数组
char s[100];
int i, n;
//字符串str输入和获取字符串长度n
gets(s);
n=strlen(s);
for(i=n-1;i>=0;i--)
printf("%c",s[i]);
//逆序输出字符串
return 0;
}
从键盘输入一个字符串,将其按逆序输出。
#include<stdio.h>
//注明字符串函数头文件
#include<string.h>
int main()
{
//定义字符数组
char s[100];
int i, n;
//字符串str输入和获取字符串长度n
gets(s);
n=strlen(s);
for(i=n-1;i>=0;i--)
printf("%c",s[i]);
//逆序输出字符串
return 0;
}