<九度 OJ>题目1098:字母统计
来源:互联网 发布:谷歌seo初级指南2016 编辑:程序博客网 时间:2024/06/06 05:40
- 题目描述:
输入一行字符串,计算其中A-Z大写字母出现的次数
- 输入:
案例可能有多组,每个案例输入为一行字符串。
- 输出:
对每个案例按A-Z的顺序输出其中大写字母出现的次数。
- 样例输入:
DFJEIWFNQLEF0395823048+_+JDLSFJDLSJFKK
- 样例输出:
A:0B:0C:0D:3E:2F:5G:0H:0I:1J:4K:2L:3M:0N:1O:0P:0Q:1R:0S:2T:0U:0V:0W:1X:0Y:0Z:0
#include <iostream>#include "string"#include "vector"using namespace std; bool countChar(const string &src, vector<int> &countTime);int main(){ string str; while (cin>>str) { if (str.length() > 1000 || str.length() < 1) break; vector<int> countTime(26, 0); countChar(str,countTime); char a = 'A'; for (int i = 0; i < 26;i++) { cout << a << ":" << countTime[i] << endl; a++; } str.erase(); } return 0;} bool countChar(const string &src, vector<int> &countTime){ if (src.length() == 0) return false; for (unsigned int i = 0; i < src.size();i++) { if (src[i] >= 'A' && src[i] <= 'Z') { int pos = src[i] - 'A'; countTime[pos]++; } } return true;}/************************************************************** Problem: 1098 User: EbowTang Language: C++ Result: Accepted Time:10 ms Memory:1520 kb****************************************************************/
注:本博文为EbowTang原创,后续可能继续更新本文。如果转载,请务必复制本条信息!
原文地址:http://blog.csdn.net/ebowtang/article/details/38374045
原作者博客:http://blog.csdn.net/ebowtang
1 0
- 九度OJ 题目1098:字母统计
- <九度 OJ>题目1098:字母统计
- 九度oj 1098 字母统计
- 九度OJ 1098 字母统计
- 九度OJ 1098:字母统计 (计数)
- C 字母统计(九度OJ 1098)
- 九度题目1098:字母统计分享代码
- 九度 Online Judge 算法 刷题 题目1098:字母统计
- 九度OJ 题目1182:统计单词
- 九度OJ 题目1021:统计字符
- 九度OJ-题目1021 统计字符
- 题目1098:字母统计
- 题目1098:字母统计
- 题目1098:字母统计
- 题目1098:字母统计
- 题目1098:字母统计
- 题目1098:字母统计
- 题目1098:字母统计
- winform DataGridView双击修改单元格的值
- 最大流最小费用流模板
- 红外协议学习笔记
- Dividing Stones
- HDU 4893 线段树裸题
- <九度 OJ>题目1098:字母统计
- android架构分析
- LiferayPortlet 中 ActionRequest 和 RenderRequest 的解释
- HDU 3506 Monkey Party 区间dp+四边形不等式
- Java记事本GUI界面设计
- 【网络流-二分图最大匹配】poj3041Asteroids
- SRBF Lighting
- CSS兼容常用技巧
- Objective C中NSArray数组排序总结(二)