// vs_test02.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
//for(int i=0;i <1000;i++){
//char* p = new char[1024*1024*4];
//delete p;
unsigned int num[26]={0},i;
char *s="iwantfindthecharacterwhichappearsthemosttimes!";
for(i=0;i<strlen(s);i++)
num[s[i]-'a']++;
for(i=0;i<26;i++)
printf("%c->%d/n",'a'+i,num[i]);
//}
system("PAUSE");
return 0;
}
本文介绍了一个简单的C++程序,该程序用于统计字符串中各字符出现的频率,并展示了一种基本的算法实现方法。通过遍历字符串并利用数组来计数每个字母的出现次数,最后输出每个字母及其对应的频率。
6022

被折叠的 条评论
为什么被折叠?



