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了(sample过的没问题)……大家看看我错哪了?

Posted by songzhenqi at 2010-07-25 21:52:54 on Problem 2403
#include <iostream>
#include <string>
using namespace std;

struct word
{
	char c[20];
	int weight;

};

int hay(int a,word dic[1001])
{   
	
	char t[10000][20];
	int sum=0;
	int i,j;
	//cout<<a<<endl;
	//cout<<"go"<<endl;
	for(i=0;i<100;i++)
	{   
		cin>>t[i];   //cout<<t[i]<<" ";
		if(!strcmp(t[i],"."))
			break;
		
		for(j=0;j<a;j++)
		{
			if(strcmp(t[i],dic[j].c)==0)
			{
				//cout<<dic[j].c<<endl;
				sum=sum+dic[j].weight;
			}

		}
		
	}
	return sum;
}

int main()
{   
	//freopen("in.txt","r",stdin);
	word dic[1001];
	int a,b;
	int i;
	cin>>a>>b;
	for(i=0;i<a;i++)
	{
		cin>>dic[i].c;
		cin>>dic[i].weight;
	}
	for(i=0;i<b;i++)
        {
                printf("%d\n",hay(a,dic));
        }
	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