输入两个字符串,计算第一个不相同的字符的差值
程序如下:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 26
int main()
{
int i,j;
char s[N];
char a[N];
gets(s);
gets(a);
if(strcmp(s,a)!=0)
{
for(i=0;i<N;i++)
{
j=s[i]-a[i];
while(j!=0)
{
printf("%d\n",j);
exit(0);
}
}
}
if(strcmp(s,a)==0)
printf("0\n");
return 0;
}
结果如下:
abd
dfe
-3
Press any key to continue