public class WorldCup {
public static void main(String[] args) {
Map<Integer,String> Footballteam = new HashMap<Integer,String>();
String[] winner = {"乌拉圭","意大利","意大利","乌拉圭","西德","巴西","巴西","英格兰",
"巴西","西德","阿根廷","意大利","阿根廷","西德","巴西","法国",
"巴西","意大利","西班牙","德国",};
int year = 1930;
for (String string:winner){
// System.out.print(year+"----");
Footballteam.put(year,string);
if (year == 1938){
year += 12;
}
else {
year += 4;
}
// System.out.println(string);
}
while (true) {
Scanner scanner = new Scanner(System.in);
System.out.println("输入年份,输0退出");
int inputyear = scanner.nextInt();
if (inputyear == 0){
break;
}
if (Footballteam.containsKey(inputyear)){
System.out.println("冠军是:"+Footballteam.get(inputyear));
}
else {
System.out.println("没有举办世界杯");
}
System.out.println("请输入球队名");
String teamname = scanner.next();
if (Footballteam.containsValue(teamname)){
Set<Integer> array = Footballteam.keySet();
for (Integer integer:array){
Footballteam.get(integer);
if (Footballteam.get(integer).equals(teamname)){
System.out.println(integer);
}
}
}
else {
System.out.println(teamname+"没有获得过冠军");
}
}
}
}
WorldCup
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...