| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
原本应该水过的……暴力之竟然Wa了(sample过的没问题)……大家看看我错哪了?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator