1666: 字符统计(水题文艺多)

题目描述
输入一篇文章,请你统计一下其中的小写字母分别有多少个
输入
输入有多行,以文件结束标识结束

输出
输出每个小写字母的个数,具体格式参见样例。

样例输入 Copy
SCARLETT O’HARA was not beautiful, but men seldom realized it when caught by her charm as the Tarleton twins were.
In her face were too sharply blended the delicate features of her mother, a Coast aristocrat of French descent, and the heavy ones of her florid Irish father.
But it was an arresting face, pointed of chin, square of jaw.
Her eyes were pale green without a touch of hazel, starred with bristly black lashes and slightly tilted at the ends.
Above them, her thick black brows slanted upward, cutting a startling oblique line in her magnolia-white skin—that skin so prized by Southern women and so carefully guarded with bonnets, veils and mittens against hot Georgia suns.
样例输出 Copy
a : 47
b : 12
c : 15
d : 20
e : 67
f : 13
g : 10
h : 33
i : 33
j : 1
k : 5
l : 25
m : 8
n : 35
o : 30
p : 5
q : 2
r : 37
s : 34
t : 51
u : 16
v : 3
w : 15
x : 0
y : 8
z : 3

#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s[1000];
	int a[26]={0};
	char c='a';
	while(gets(s))
	{
		for(int k=0;k<26;k++)
		{
			for(int i=0;i<strlen(s);i++)
			{
				if(s[i]==c)
				a[k]++;
			}
			c++;
		}
		c='a';
	}
	char d='a';
	for(int i=0;i<26;i++)
	{
		cout<<d<<" "<<": "<<a[i]<<endl;
		d++;
	}
	return 0;
 } 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值