| ||||||||||
| 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 | |||||||||
太水了,注意,累计计算,贴代码。#include <iostream>
#include <string>
using namespace std;
struct node
{
long value;
string word;
};
int main(int argc, char* argv[])
{
string str;
int x,y,n,i,j,sum,k,m;
bool flag;
cin>>m>>n;
node *no = new node[m];
for ( i = 0 ; i < m ; i++)
{
cin>>no[i].word;
cin>>no[i].value;
}
while (n--)
{
cin>>str;
sum = 0 ;
while (str!=".")
{
for (j = 0 ; j < m ; j++)
{
if( no[j].word == str )
{
no[j].visit = true;
sum += no[j].value;
}
}
cin>>str;
}
cout<<sum<<endl;
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator