谁能教我这个基础编程
读取一个文件夹的每个字母output 是每个字母出现的次数
比如说,文件里是:"how are you"
就是 h:1 o:2 w:1 a:1 r:1........
然后还得计算write space和uppercase and lower case letters
谢谢大侠
2010-04-06 03:11
2010-04-06 14:07
程序代码:#include <iostream>
using namespace std;
int main()
{
char ch[128];
char str[255];
int w=0;u=0;l=0;
memset(ch,0,128);
cin>>str;
int asc;
for(int i=0;str[i]!='\0';++i)
{
asc=str[i];
ch[asc]++;
if (asc>='A' && asc<='Z')++u;
if(asc>='a' && asc<='z')++l;
if(asc==32)++w;
}
cout <<"w:" << w <<endl;
cout <<"l:" << l << endl;
cout <<"u:" << u << endl;
for(int i=32;i<128;++i)
if(ch[i]>0)cout << (char)i << "有:" << ch[i]<< endl;
}
2010-04-06 20:59