标题:如何统计字母的使用频率
只看楼主
zbj0592
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2007-6-28
得分:0 
太好了!!!
我朋友帮我做了一个(见下),但是看不懂,好像不是C++的。大家能帮忙改改吗?感激不尽啊!

#include <cstdio>
#include <memory>
int count[256];
int main()
{
int i;
char ch;
memset(count,0,sizeof(count));
for (i=0;i<200;i++)
{
scanf("%c",&ch);
count[ch]++;
}
for (i='A';i<='Z';i++)
printf("The frequency of %c is %lf\n",i,count[i]/200.0);
for (i='a';i<='a';i++)
printf("The frequency of %c is %lf\n",i,count[i]/200.0);
return 0;
}
2007-06-29 11:13
zbj0592
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2007-6-28
得分:0 

各位快帮帮忙吧,再两天就要上交了!唉!

2007-06-29 16:47



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-150958-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.120345 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved