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 wzp_moon at 2015-08-12 16:09:25 on Problem 2136
#include <stdio.h>

int main(void)
{
	int i,k,n,j;
	int max;
	char a[73];
	int num[26] = {0};
	for(i = 0; i < 4; i++)
	{
		scanf("%[^\n]s",a);
		getchar();
		j = 0;
		while(a[j] != '\0')
		{
			switch (a[j])
			{
				case 'A':
					num[0]++;
					break;
				case 'B':
					num[1]++;
					break;
				case 'C':
					num[2]++;
					break;
				case 'D':
					num[3]++;
					break;
				case 'E':
					num[4]++;
					break;
				case 'F':
					num[5]++;
					break;
				case 'G':
					num[6]++;
					break;
				case 'H':
					num[7]++;
					break;
				case 'I':
					num[8]++;
					break;
				case 'J':
					num[9]++;
					break;
				case 'K':
					num[10]++;
					break;
				case 'L':
					num[11]++;
					break;
				case 'M':
					num[12]++;
					break;
				case 'N':
					num[13]++;
					break;
				case 'O':
					num[14]++;
					break;
				case 'P':
					num[15]++;
					break;
				case 'Q':
					num[16]++;
					break;
				case 'R':
					num[17]++;
					break;
				case 'S':
					num[18]++;
					break;
				case 'T':
					num[19]++;
					break;
				case 'U':
					num[20]++;
					break;
				case 'V':
					num[21]++;
					break;
				case 'W':
					num[22]++;
					break;
				case 'X':
					num[23]++;
					break;
				case 'Y':
					num[24]++;
					break;
				case 'Z':
					num[25]++;
					break;
				default:
					break;
			}
			j++;
		}
	}
	max = num[0];
	//找到个数最大的
	for (k = 1; k <= 26; k++)
	{
		if (num[k] >= max)
		{
			max = num[k];
		}
		else
		{
			/*do nothing*/
		}
		
	}

	for(n = max;n >= 1;n--)
	{
		for (k = 0; k < 26; k++)
		{
			if (num[k] < n)
			{
				printf("  ");
			} 
			else
			{
				num[k]--;
				printf("* ");
			}
		}
		printf("\n");/*最后一行前的回车*/
	}
	
	for(i='A';i<='Z';i++)
	{
		printf("%c ",i);
	}
	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