搜索

...从键盘输入若干字符(当输入#时结束),分别统计出大、小写字母和数字符...

发布网友 发布时间:2024-10-23 21:32

我来回答

2个回答

热心网友 时间:2024-10-27 05:14

#include "stdio.h"
main()
{char c,sum1=0,sum2=0,number=0;
c=getchar();
while(c!='#')
{
if(c>='A'&&c<='Z') sum1++;
else if(c>='a'&&c<='z') sum2++;
else if(c>='0'&&c<='9') number++;
c=getchar();
}
printf("大写字母:%d,小写字母:%d,数字:%d",sum1,sum2,number);
}

热心网友 时间:2024-10-27 05:13

#include<stdio.h>

main()

       int count_Lowcase,count_Highcase,count_Number;
       int i,j,c;
       char str[256];
       scanf("%s",str);

       count_Lowcase= count_Highcase = count_Number = 0;
       i=1;
       c = 0;
       while( str[c] && str[c] != '#'  )
       {
              if(str[c]>='0' && str[c]<='9')
              {
                    ++count_Number ;
              }
              else if(str[c]>='a' && str[c]<='z' )
              {
                     ++count_Lowcase;
              }
              else if(str[c]>='A' && str[c]<='Z' )
              {
                  ++count_Highcase  ;
              }              
              ++c;
       }
       printf("Lowercase:%d\n",count_Lowcase);
       printf("Uppercase:%d\n",count_Highcase  );
        printf("Number:%d\n",count_Number);
}
声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。
E-MAIL:11247931@qq.com
Top