编写函数,使其实现返回str1和str2分别指向的字符串中大写字母个数的差值

  1. Cprog912:
    #include <stdio.h>
    #include <string.h>
    int upperComp(char *str1, char *str2)
    {/**/

/**/
}
int main()
{
int rela;
char a[64],b[64];
printf("Please input string a:");
gets(a);
printf("Please input string b:");
gets(b);
rela=upperComp(a,b);
printf("Difference:%d",rela);
return 0;
}


#include <stdio.h>
#include <string.h>
int upperComp(char *str1, char *str2)
{
    int s1=0,s2=0;
    char *p1=str1,*p2=str2;
    while(*p1!='\0')
    {
       if(*p1>='A'&&*p1<='Z')
          s1++;    
       p1++;
    }
    while(*p2!='\0')
    {
        if(*p2>='A'&&*p2<='Z')
           s2++;
        p2++;
    }
    return s1-s2;
}
int main()
{
   int rela;
   char a[64],b[64];
   printf("Please input string a:");
   gets(a);
   printf("Please input string b:");
   gets(b);
   rela=upperComp(a,b);
   printf("Difference:%d",rela);
   return 0;
}