#11185: C++


dicksobig (迪克筆所˙比隔)

School : 臺北市私立延平高級中學
ID : 54477
IP address : [140.115.205.44]
Last Login :
2021-10-07 15:39:32
a253. 王老先生的磨菇田 -- 2011成功高中校內賽初賽第二題 | From: [203.72.178.252] | Post Date : 2016-07-18 14:28

#include <iostream>
#include <stdio.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
int sum[101]={0};
int s,n;
for(int i=1; i<=2; i++)
{
while(cin>>s)
{
if(s==-1) break;
cin>>n;
sum[s]+=n;
}
}
for(int i=0; i<=100; i++)
{
if(sum[i]==0) continue;
else cout<<i<<' '<<sum[i]<<endl;
}
}

 
ZeroJudge Forum