| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
求助第2136题
不知错在哪里了,那位能帮忙指出一下,不胜感激。
#include<stdio.h>
int main()
{
int i,j,ch[26],max,count=0,k;
char str[75];
for(i=0;i<26;i++)ch[i]=0;
for(i=0;i<4;i++)
{
gets(str);
for(j=0;str[j] != '\0'; j++)
if(str[j] >= 'A' && str[j] <= 'Z')ch[str[j]-'A']++;
}
for(i=0;i<26;i++)
{
if(ch[i]!=0){
ch[i]++;
count++;
}
}
max=0;
for(i=0;i<26;i++)
if(ch[i]>max)max=ch[i];
for(j=max;j>=2;j--)
{
k=0;
for(i=0;i<26;i++)
{
k++;
if(ch[i]==j){
printf("*");ch[i]--;
if(k!=count)printf(" ");
else break;
}
else if(ch[i]!=0){printf(" ");
if(k!=count)printf(" ");
else break;
}
}
printf("\n");
}
k=0;
for(i=0;i<26;i++)
{
k++;
if(ch[i]!=0){
printf("%c",'A'+i);
if(k!=count)printf(" ");
else break;
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator