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

找不出错误的WA!!!有兴趣的看看

Posted by nothing828 at 2010-02-23 22:45:09 on Problem 2136
#include<iostream>
using namespace std;

int a[30];
char word[150];
char map[300][30];//保存要输出的图形

int main()
{
	int i,j,len,max,last;
	memset(a,0,sizeof(a));
	for(i=0;i<4;i++)//确定相应字母个数
	{
		gets(word);
		len=strlen(word);
		for(j=0;j<len;j++)
		{
			if(word[j]>='A' && word[j]<='Z')
				a[word[j]-'A']++;
		}
	}
	max=0;//记录出现次数最多的字母的个数
	for(i=0;i<26;i++)
	{
		if(max<a[i])
			max=a[i];
		for(j=0;j<a[i];j++)
			map[j][i]='*';
	}
	for(i=max-1;i>=0;i--)
	{
		last=-1;
		for(j=0;j<26;j++)//确定多于空格开始的位置
		{
			if(map[i][j]=='*')
				last=j;
		}
		map[i][last+1]='.';//'.'之后是多于的空格(包括'.'的位置)
	}
	for(i=max-1;i>=0;i--)//图形输出
	{
		for(j=0;j<26;j++)
		{
			if(map[i][j+1]!='.')
				printf("%c ",map[i][j]);
			else
			{
				printf("*\n");
				break;
			}
		}
	}
	for(i='A';i<'Z';i++)
		printf("%c ",i);
	printf("Z\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