读取一个字符串,字符串可能含有空格,将字符串逆转,原来的字符串与逆转后字符串相同,输出0,原字符串小于逆转后字符串输出-1,大于逆转后字符串输出1。例如输入 hello,逆转后的字符串为 olleh,因为hello 小于 olleh,所以输出-1,注意最后的判断一定要这么写,因为strcmp标准C中并不是返回-1和1,而是负值和正值
输入一个字符串,例如 hello,当如输入的字符串也可能是 how are you,含有空格的字符串Output输出是一个整型数,如果输入的字符串是hello,那么输出的整型数为-1
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
int main()
{
int i,j;//i旧数组,j新数组
char c[100];
char d[100];
int result=strcmp(c,d);
gets(c);
for(i=strlen(c)-1,j=0;i>=0;i--,j++)//数组长度减去最后一个换行符
{
d[j]=c[i];
}
d[j]='\0';//让j结束
puts(d);
if(result<0)
{
printf("%d\n",-1);
}
else if(result>0)
{
printf("%d\n",0);
}
else
{
printf("%d\n",1);
}
return 0;
}
int result = strcmp(c, d);
if (result < 0)