回复 12楼 grmmylbs
// VS 编译器。 程序要求是 字符串以"."为结束符号,正反读相同YES.不同 NO。
#include "stdafx.h"
#include "string.h"
#define size 20
int panduan(char *p, int len)
{
int i = 0;
char *q;
q=p + len-1;
while (i < len/2)
{
if (*(p + i) !=*( q - i))
{
printf("%d,%d\n",*(p+i), *(q-i));
return -1;
}i++;
}
return 1;
}
int main()
{
char a[size] = "\0";
int i = 0;
int k;
int len;
printf("please input a enilish string:");
do
{
scanf_s("%c", &a[i]);
i++;
} while (a[i-1] != '.');
printf("the yingyu juzi is:");
puts(a);
len = strlen(a);
k=panduan(a,len);
if (k > 0)
printf("yes,the same\n");
else
printf("no, it isn't\n");
return 0;
}
编译结果是都是输出 -1