求一简单的c语言编程题80行左右 大一用的 c++环境下运行的 简单点的

如题所述

以下是统计26个英文小写字母出现的次数
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void Stat(char *str,int count[])
{
int i;
for(i=0;i<26;i++)count[i]=0;
for(i=0;i<strlen(str);i++)
{
if(str[i]=='a')count[0]++;
else if(str[i]=='b')count[1]++;
else if(str[i]=='c')count[2]++;
else if(str[i]=='d')count[3]++;
else if(str[i]=='e')count[4]++;
else if(str[i]=='f')count[5]++;
else if(str[i]=='g')count[6]++;
else if(str[i]=='h')count[7]++;
else if(str[i]=='i')count[8]++;
else if(str[i]=='j')count[9]++;
else if(str[i]=='k')count[10]++;
else if(str[i]=='l')count[11]++;
else if(str[i]=='m')count[12]++;
else if(str[i]=='n')count[13]++;
else if(str[i]=='o')count[14]++;
else if(str[i]=='p')count[15]++;
else if(str[i]=='q')count[16]++;
else if(str[i]=='r')count[17]++;
else if(str[i]=='s')count[18]++;
else if(str[i]=='t')count[19]++;
else if(str[i]=='u')count[20]++;
else if(str[i]=='v')count[21]++;
else if(str[i]=='w')count[22]++;
else if(str[i]=='x')count[23]++;
else if(str[i]=='y')count[24]++;
else if(str[i]=='z')count[25]++;
}
}
int main(void)
{
char str[10000];
int i,count[26];
printf("请输入a~z的字符串:\n");
gets(str);
Stat(str,count);
for(i=0;i<26;i++)
printf("%c:%d\n",i+'a',count[i]);
system("pause");
return 0;
}
祝你愉快!
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-06-19
C/C++感兴趣的,欢迎来百度贴吧codeblocks吧玩
第2个回答  2013-06-19
关键是你想编个什么软件,做什么用的。
相似回答
大家正在搜