首页 > 试题广场 >

字母统计

[编程题]字母统计
  • 热度指数:17146 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
输入一行字符串,计算其中A-Z大写字母出现的次数

输入描述:
案例可能有多组,每个案例输入为一行字符串。


输出描述:
对每个案例按A-Z的顺序输出其中大写字母出现的次数。
示例1

输入

DFJEIWFNQLEF0395823048+_+JDLSFJDLSJFKK

输出

A:0
B:0
C:0
D:3
E:2
F:5
G:0
H:0
I:1
J:4
K:2
L:3
M:0
N:1
O:0
P:0
Q:1
R:0
S:2
T:0
U:0
V:0
W:1
X:0
Y:0
Z:0
头像 DioDid
发表于 2022-02-02 02:32:56
#include <stdio.h> #include <string.h> int main() { char C=1; int ASCII_COUNT[128]={0}; C=getchar(); while(C!='\n') 展开全文
头像 复旦周杰伦
发表于 2023-03-02 22:11:03
#include <iostream> #include "string" #include "cstdio" #include "map" using namespace std; int main() { string str; map<char, int&g 展开全文
头像 MrMello
发表于 2023-03-16 11:05:28
#include <stdio.h> #include <string.h> int main(){ char arr[100]; //输入的最大长度 scanf("%s", arr); int len = strlen(arr); int 展开全文
头像 天乔巴夏、
发表于 2022-01-15 19:29:03
#include<iostream> using namespace std; const int N = 30; int cnt[N]; int main() { string s; while(cin >> s) { for 展开全文
头像 BrianWu
发表于 2021-07-06 20:21:27
/*描述输入一行字符串,计算其中A-Z大写字母出现的次数输入描述:案例可能有多组,每个案例输入为一行字符串。输出描述:对每个案例按A-Z的顺序输出其中大写字母出现的次数。*/ #include<iostream> #include<string> #include<cs 展开全文
头像 aaaawei
发表于 2021-01-12 13:29:46
include include include using namespace std;int main(){ string str; while(getline(cin,str)){//循环输入一行 for(char i='A';i<='Z';++i){ //从a到 展开全文
头像 shininggirls01
发表于 2024-01-29 16:53:57
#include <iostream> using namespace std; int main() { string str; int count; while (getline(cin, str)) { for (int j = 'A'; 展开全文
头像 yan杉
发表于 2024-03-26 12:52:20
#include <iostream> #include <string> #include <cstdio> using namespace std; int main() { int arr[26]={0}; string str; 展开全文
头像 lyw菌
发表于 2023-03-16 09:36:28
//注意到'A'-'A'=0,用数组下标代表各个字母即可。 // 这种思想用的还是挺多的,进制转换,字符串的题经常用。 #include "stdio.h" #include "string" using namespace std; int main(){ int letter[26]; 展开全文
头像 小徐小徐啊啊
发表于 2024-03-12 16:32:36
#include <stdio.h> #include <string.h> int main() { char a[100]; int b[26]={0}; char c[26]={'A','B','C','D','E','F','G','H','I', 展开全文