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

示例

#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 零基础布艺DIY工坊 教你做超萌猫头鹰钥匙包
16 三棵树漆怎么样?三棵树漆官方网站
17 家庭“装修套餐”中猫腻你知道吗?
18 小空间大浴望 卫浴间装修巧支招