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 alpc85 at 2008-08-21 16:27:47 on Problem 1119
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <memory.h>
using namespace std;

string _search[25100];
double stat[25100];
double sum;
string unify(string matter)
{
   int len;
   string change;
   change = "";
   if(matter == "----------") return matter;
   for(len = 0; len < matter.size(); len++)
   {
	  if( (matter[len] >= 'a' && matter[len] <= 'z' ) || ( matter[len] >= '0' && matter[len] <= '9' ) ) change += matter[len];
	  else
		  if(matter[len] >= 'A' && matter[len] <= 'Z') change += char(int(matter[len]) + 32);
   }
   return change;
}
int main()
{
	int i = 0,count;
	memset( stat, 0, sizeof(stat));
	string now,change;
	do 
	{
		cin >> now;
		now = unify(now);
		if(now != "----------") _search[i++] = now;
		else break;
	} while (true);

	count = i ;

	do 
	{
		cin >> now;
		if( now == "----------") return 0;
		do 
		{
			change = "";
			change = unify(now);
			for(i = 0; i < count; i++)
				if(change == _search[i]) 
				{
					stat[i]++;
					break;
				}
			cin >> now;
		} while (now != "----------");
		sum = 0;
		for(i = 0; i <count; i++)
		{
			if(stat[i] != 0) sum += sqrt(stat[i]);
		}
		printf("%.2lf\n",sum);
		memset( stat, 0, sizeof(stat));
	} while (true);
   
}

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