关于字符串逆转后判段大小

#include<stdio.h>
#include<string.h>
int main()
{
  char c[100],d[100];
  int i,j,len;
  gets(c);
  len=strlen(c);
  for(i=0;i<len;i++)
    d[len-1-i]=c[i];//数组d里面用len-1-i是因为数组从d[0]~d[len-1]
int result = strcmp(c, d);
  
if (result < 0)
{
printf("%d\n",-1);
}
else if (result > 0)
{
printf("%d\n", 1);
}
else {
printf("%d\n", 0);
}
  return 0;
}

 

posted @ 2022-07-23 20:24  携橘亡命天涯  阅读(14)  评论(0)    收藏  举报