网易云课堂java进阶第三周作业

http://mooc.study.163.com/learn/ZJU-1000004001?tid=1000005000#/learn/ojhw?id=1000215000

 1 package J3;
 2 import java.util.*;
 3 public class Test2 {
 4     private HashMap<String, Integer> city = new HashMap<String, Integer>();
 5     private int cityAmount = 0;
 6     
 7     public void init(){
 8         Scanner in = new Scanner(System.in);
 9         String next = new String();
10         while( !(next = in.next()).equals("###")){
11             
12             city.put(next, cityAmount);
13             cityAmount++;
14         }
15 //        System.out.println(cityAmount);
16         int[][] table = new int[cityAmount][cityAmount];
17         for( int i = 0; i < cityAmount; i++ ){
18             for( int j = 0; j < cityAmount; j++){
19                 table[i][j] = in.nextInt();
20             }
21         }
22         String compareA = new String();
23         String compareB = new String();
24         compareA = in.next();
25         compareB = in.next();
26         in.close();
27         System.out.println(table[city.get(compareA)][city.get(compareB)]);
28     }
29     
30     public static void main(String[] args){
31         new Test2().init();
32     }
33 }

哎,没有思路时,首先想到的还是过程化解决问题,,,还是读书少啊。。

转载于:https://www.cnblogs.com/happi1y/p/4755496.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值