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

一次AC,贴下代码,水水更健康

Posted by xj_nan at 2009-06-14 12:29:11 on Problem 2136
#include <iostream>
using namespace std;
int main()
{
	char a[4][72],c[28];
	int b[28]={0},t,temp,i,j,max=0;
	
	for(i=0;i<4;i++)
		gets(a[i]);

	for(i=0;i<4;i++)                                         //用数组b记住各个字符出现的词数
		for(j=0;j<strlen(a[i]);j++)
		{
			if(a[i][j]<='Z'&&a[i][j]>='A')
			{
				temp=a[i][j]-'A';
				b[temp]++;
			}
		}

	for(i=0;i<26;i++)										//找出最大值
		if(max<b[i])
			max=b[i];
	for(i=max;i>0;i--)
	{
		temp=0;
		for(j=0;j<26;j++)									//清零
			c[j]='\0';
		for(j=0;j<26;j++)									
		{
			if(b[j]==i)
			{
				for(t=temp;t<j;t++)
						c[t]=' ';
				c[j]='*';
				c[j+1]='\0';
				b[j]--;
				temp=j+1;
			}
		}
		j=0;
		while(c[j])
		{
			if(j==0)
				cout<<c[j];
			else
				cout<<' '<<c[j];
			j++;
		}
		cout<<endl;
	}
	cout <<"A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"<<endl;
	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