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

示例

#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 生日广州男生祝福语简短