接下来的程序是识别字符串中的字母,数字和特殊字符的总数-

示例

#include<stdio.h>
#include<ctype.h>
void main(){
   //Declaring integer for number determination, string//
   int number;
   char string[50];
   int alphabets=0;
   int digits=0;
   int special=0;
   //Reading User I/p//
   printf("输入字符串:");
   gets(string);
   for(number=0;string[number]!='\0';number++){
      if(string[number]>='a'&&string[number]<='z'||string[number]>='A'&&string[number]<='Z'){
         alphabets=alphabets+1;
         //alphabets++;
      }else if(string[number]>='0'&&string[number]<='9'){
         digits=digits+1;
         //digits++;
      }else{
         special=special+1;
         //special++;
      }
   }
   //Printing number of alphabets, number of digits, number of special characters//
   printf("The number of alphabets in the string is : %d\n",alphabets);
   printf("The number of digits in the string is : %d\n",digits);
   printf("The number of special characters in the string is : %d\n",special);
}
输出结果
输入字符串:The number of alphabets in the string is : 0
The number of digits in the string is : 0
The number of special characters in the string is : 1

热门推荐

1 退伍祝福语老师简短
2 给新娘彩礼祝福语简短
3 自由 生日祝福语简短独特
4 春节文章开头祝福语简短
5 订婚典礼文案祝福语简短
6 爷爷庆生文案祝福语简短
7 宿舍迎新祝福语简短英文
8 长辈鲜花祝福语卡片简短
9 培训机构升班祝福语简短
10 新人红包祝福语简短精辟
11 幼师给毕业祝福语简短
12 生日高考祝福语妹妹简短
13 下飞机祝福语简短英文
14 元宵发客户祝福语简短
15 爸妈金婚文案祝福语简短
16 新郎朋友红包祝福语简短
17 虎年五一祝福语大全简短
18 出阁宴祝福语姐姐简短