#include<stdio.h>
#include<string.h>
void com(char *s1, char *s2)
{
int i, j, k;
int a=0, b=0;
int l1, l2;
l1 = strlen(s1);
l2 = strlen(s2);
for (i = 0; i < l1; i++)
{
a += s1[i] - 'A';
}
for (i = 0; i < l2; i++)
{
b += s2[i] - 'A';
}
if (a == b)
{
printf("0");
}
else if (a > b)
{
printf("1");
}
else
printf("-1");
}
int main()
{
char s1[50], s2[50];
gets_s(s1); gets_s(s2);
com(s1, s2);
return 0;
}
实现一个字符串大小比较函数,若有两个字符串s1和s2,s1与s2相等返回0,s1>s2返回1,s1<s2返回-1
![](https://img-home.csdnimg.cn/images/20240711042549.png)