Java 1064:奥运奖牌计数
时间: 2023-07-30 19:07:28 浏览: 220
好的,我可以帮你解决这个问题。请问你需要什么样的帮助?
如果你需要一个 Java 程序来计算奥运会的奖牌数,可以考虑以下代码:
```java
public class OlympicMedalCount {
public static void main(String[] args) {
int[][] medalCount = {
{36, 38, 38},
{41, 37, 38},
{27, 23, 17},
{26, 18, 26},
{17, 19, 26},
{16, 22, 17},
{14, 14, 17},
{11, 7, 12}
};
String[] countries = {"美国", "中国", "日本", "澳大利亚", "俄罗斯", "英国", "德国", "法国"};
for (int i = 0; i < countries.length; i++) {
int gold = medalCount[i][0];
int silver = medalCount[i][1];
int bronze = medalCount[i][2];
int total = gold + silver + bronze;
System.out.println(countries[i] + "获得了 " + gold + " 金牌," + silver + " 银牌," + bronze + " 铜牌,共计 " + total + " 枚奖牌。");
}
}
}
```
这个程序会输出每个国家获得的奖牌数和奖牌总数。你可以根据你的具体需求进行修改。
阅读全文