| ||||||||||
| 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 | |||||||||
贴一个烂代码#include<stdio.h>
#include<string.h>
int main()
{
char ch[80];
int i,j,k;
int a[26]={0},n=4;
int max,count;
while(n--)
{
gets(ch);
int len=strlen(ch);
for(i=0;i<len;i++)
if(ch[i]>='A'&&ch[i]<='Z')
a[ch[i]-'A']++;
}
max=0;
for(i=0;i<26;i++)
if(a[i]>max)max=a[i];
count=0;
for(i=0;i<max;i++)
for(j=0;j<26;j++)
{
if(a[j]!=max-i)printf(" ");
else
{
printf("*");
a[j]--;
}
for(k=j+1;k<26;k++)
if(a[k]==max-i)
{
count++;
printf(" ");
break;
}
if(count==0)
{
printf("\n");
break;
}
count=0;
}
for(i=0;i<26;i++)
{
printf("%c",i+'A');
if(i!=25)printf(" ");
else printf("\n");
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator