Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

贴一个烂代码

Posted by lanseniao at 2009-03-06 13:43:13 on Problem 2136
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator