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

示例

#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 教师闺蜜祝福语简短