字符串统计
来源:互联网 发布:鲁大师 硬件体检 优化 编辑:程序博客网 时间:2024/05/18 03:45
/** 程序的版权和版本声明部分* Copyright (c)2013, 烟台大学计算机学院学生* All rightsreserved.* 作 者:冯冬影* 完成日期:2013 年11 月 30日* 版本号: v1.0* 输入描述:输入字符串* 问题描述:计算出大小写字母、数字的个数,* 程序输出:输出符合要求的个数* 问题分析:*/#include <iostream>#include <cstdio>using namespace std;int main (){ char str[50]; int i=0,n=0,g=0,j=0,k=0; cout <<"输入字符串:"; gets (str); while (str[i]!='\0') { if(str[i]>='0'&&str[i]<='9') n++; if(str[i]=='A') g++; if(str[i]>='a'&&str[i]<='z') j++; if(str[i]>='A'&&str[i]<='Z') k++; i++; } cout<<"其中的数字个数是:"<<n<<endl; cout <<"其中A的个数是:"<<g<<endl; cout<<"其中的大写字母个数是:"<<k<<endl; cout <<"其中的小写字母个数是:"<<j<<endl; return 0;}
运行结果
- 统计字符串
- 统计字符串
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 统计字符串
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 纯虚函数也可以有函数体
- 数据库基础--游标
- iOS 邮箱验证
- 在jvm5.0上垃圾回收调优(1)
- Qt下 汉字转换拼音
- 字符串统计
- Linux设备驱动之——I2C总线
- ios开发获取SIM卡信息
- AS3.0 运算符
- ubuntu与windows时间设置及同步问题
- SHTSC记 13.11.30
- LINUX内核符号表
- Windows Storage Server 2008 R2 Standard(64位),Win7(64位)的PLSQL不能连接oracle的解决办法
- 第14周项目12-字符串统计(二)