/*
將兩個字符串s1,s2進行比較,如果s1>s2,則輸出一個正數。如果s1 = s2,輸出零。如果s1 < s2,
輸出一個負數,不用strcmp函數,輸出的正數或者負數的絕對值應該是比較兩字符串相應字符的ascii碼的差值。
*/
#include <stdio.h>
#include <stdlib.h>
int strCmp(char *pStr1,char *pStr2)
{
int d = 0;
while(*pStr1 != '\0' && *pStr2 != '\0')
{
d = *pStr1 - *pStr2;
if(d != 0)
{
break;
}
++pStr1;
++pStr2;
}
d = *pStr1 - *pStr2;
return d;
}
int main()
{
char str1[100];
char str2[100];
scanf("%s %s", str1, str2);
printf("%d", strCmp(str1,str2));
return 0;
}