#11185: C++


dicksobig (迪克筆所˙比隔)

學校 : 臺北市私立延平高級中學
編號 : 54477
來源 : [140.115.205.44]
最後登入時間 :
2021-10-07 15:39:32
a253. 王老先生的磨菇田 -- 2011成功高中校內賽初賽第二題 | From: [203.72.178.252] | 發表日期 : 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