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

为什么我把WORD[3000]改成WORD[500]就是从RTE到WA?感觉有点反了.

Posted by Essence_me at 2005-07-12 22:36:46 on Problem 2471
#include <stdio.h>
#include <string.h>
#include <math.h>
char finish[9]="BULLSHIT";
char str[500],word[5000][25],w[25];
int i;
int numword=0,numgame=0,pletter=0,pstr=0,pwordend=0,real,end;
void main()
{
	while(gets(str)!=0)
	{
		pstr=0;
		while(str[pstr]!='\0')
		{
			pletter=0;
			real=0;
			while((str[pstr]<='z'&&str[pstr]>='a')||(str[pstr]<='Z'&&str[pstr]>='A'))
			{
				if(real==0)real=1;
				w[pletter]=str[pstr];
				pletter++;
				pstr++;
			}
			w[pletter]='\0';
			if(real)
				if(strcmp(w,finish)!=0)
				{
					for(i=0;i<strlen(str);i++)
					{
						if(w[i]<='Z'&&w[i]>='A')w[i]=w[i]-'A'+'a';
					}
					real=1;
					for(i=pwordend;i<numword;i++)
					{
						if(strcmp(word[i],w)==0)
						{
							real=0;
							break;
						}
					}
					if(real)
					{
						strcpy(word[numword],w);
						numword++;
					}
				}
				else
				{
					numgame++;
					pwordend=numword;
				}
			else pstr++;
		}
	}
	numword=pwordend;
	end=numgame;
	for(i=2;i<=end;i++)
	{
		if(numgame%i==0&&numword%i==0)
		{
			numgame=numgame/i;
			numword=numword/i;
			i--;
		}
	}
	printf("%d / %d\n",numword,numgame);
}

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