#include
#include
#include
int main()
{
FILE *fp;
char ch[2];
int count[26],i,j;
memset(count,0,sizeof(count));
if((fp=fopen("data.in","r"))==NULL)
{
printf("can not open this file.\n");
exit(0);
}
while(!feof(fp))
{
fgets(ch,2,fp); //每次读取两个字符
for(i=65;i<=90;i++)
{
for(j=0;j<2;j++)
{
if(i==ch[j]||(i+32)==ch[j])
count[i-65]++;
}
}
}
for(i=0;i<26;i++)
{
printf("%c,%d\n",i+65,count[i]);
}
fclose(fp);
return 0;
}
#include
#include
int main()
{
int a[26];
ifstream f("data.in");
while (!f.eof()) {
char c;
f>>c;
if ((c >='a') && (c <= 'z'))
++a[c - 'a'];
else if ((c >= 'A') && (c <= 'Z'))
++a[c - 'A'];
}
f.close()
for (unsigned i = 0; i < 26; ++i)
std::cout<<'A' + i<<':'< return 0;
}