问题描述:
2008年北京奥运会,A国的运动员参与了n天的决赛项目(1≤n≤17)。现在要统计一下A国所获得的金、银、铜牌数目及总奖牌数。
输入
输入n+1行,第1行是A国参与决赛项目的天数n,其后n行,每一行是该国某一天获得的金、银、铜牌数目,以一个空格分开。
输出
输出1行,包括4个整数,为A国所获得的金、银、铜牌总数及总奖牌数,以一个空格分开。
样例
输入
3
1 0 3
3 1 0
0 3 0
输出
4 4 3 11
Java代码:
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner rd=new Scanner(System.in);
int a=rd.nextInt();
int b=0;
int c=0;
int d=0;
for(int i=0;i
b+=rd.nextInt();
c+=rd.nextInt();
d+=rd.nextInt();
}
System.out.println(b);
System.out.println(c);
System.out.println(d);
System.out.println(b+c+d);
}
}
作者:KJ.JK
本文仅用于交流学习,未经作者允许,禁止转载,更勿做其他用途,违者必究。
文章对你有所帮助的话,欢迎给个赞或者 star,你的支持是对作者最大的鼓励,不足之处可以在评论区多多指正,交流学习



