华为OJ试题:输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
来源:互联网 发布:淘宝茶叶为什么便宜 编辑:程序博客网 时间:2024/05/17 02:01
#include <stdarg.h>#include <stdio.h>#include <iostream>#include <vector>#include <string.h>#include <algorithm>#include <stdlib.h>#include <memory>#include <string.h>#include <set>#include <map>#include <sstream>#include <string>using namespace std;/* 求英文字母的大小*/static int getEnglishCharCount(string str){int len = str.size();int i = 0;int count = 0;for (i = 0; i < len; i++){if ((str[i] >= 'a' && str[i] <= 'z') || (str[i] >= 'A' && str[i] <= 'Z')){++count;}}return count;}/* 求空格字符的个数 */static int getBlankCharCount(string str){int len = str.size();int i = 0;int count = 0;for (i = 0; i < len; i++){if (str[i] == ' '){++count;}}return count;}/* 求数字字符的个数 */static int getNumberCharCount(string str){int len = str.size();int i = 0;int count = 0;for (i = 0; i < len; i++){if (str[i] >= '0' && str[i] <= '9'){++count;}}return count;}/* 统计出其它字符的个数 */static int getOtherCharCount(string str){int count = str.size() - getEnglishCharCount(str);count = count - getBlankCharCount(str);count = count - getNumberCharCount(str);return count;}int main(){string str;getline(cin, str);cout << getEnglishCharCount(str) << endl;cout << getBlankCharCount(str) << endl;cout << getNumberCharCount(str) << endl;cout << getOtherCharCount(str) << endl;return 0;}
0 0
- 华为OJ试题:输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
- 华为OJ题库-输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
- 华为oj:输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
- 华为oj 输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
- 【华为OJ】【032-输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数】
- 华为OJ——输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
- 【华为OJ】输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
- 华为OJ 初级:输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
- 【华为 OJ】输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数。
- 华为OJ——输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
- [华为OJ--C++]032-输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
- 华为OJ——输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
- 输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
- 输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
- 输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
- 输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
- 输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
- 输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
- maven 使用maven profile实现多环境可移植构建
- [boost] Windows下编译
- YARN原理及其工作流程
- POJ 1422 Air Raid (最小路径覆盖)
- linux下 /etc/profile、~/.bash_profile ~/.profile的执行过程
- 华为OJ试题:输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
- ffmpeg中的时间
- 策略模式
- 那条linq语句为啥这么慢
- 3sum closest to target
- 转换jdk安装路径中有空格的情况
- bzoj1650: [Usaco2006 Dec]River Hopscotch 跳石子
- Regionals 2007 >> Europe - Southwestern Ladies' Choice 稳定婚姻问题 uva live 3989
- 2. --SQLite 打开数据库