HW7.17
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HW7.17相关的知识,希望对你有一定的参考价值。
1 import java.util.Scanner; 2 3 public class Solution 4 { 5 public static void main(String[] args) 6 { 7 Scanner input = new Scanner(System.in); 8 9 int n = input.nextInt(); 10 int limit = input.nextInt(); 11 12 int[][] borrowers = new int[n][n]; 13 14 for(int i = 0; i < n; i++) 15 { 16 borrowers[i][i] = input.nextInt(); 17 int volume = input.nextInt(); 18 int[] temp = new int[volume * 2]; 19 for(int j = 0; j < temp.length; j++) 20 temp[j] = input.nextInt(); 21 for(int j = 1; j < temp.length; j += 2) 22 borrowers[i][temp[j - 1]] = temp[j]; 23 } 24 25 boolean existChange = false; 26 while(true) 27 { 28 existChange = false; 29 for(int i = 0; i < n; i++) 30 { 31 int sum = 0; 32 for(int j = 0; j < n; j++) 33 sum += borrowers[i][j]; 34 if(sum < limit) 35 { 36 System.out.println("Unsafe Bank -- " + i); 37 existChange = true; 38 for(int j = 0; j < n; j++) 39 if(j != i) 40 borrowers[j][i] = 0; 41 } 42 } 43 if(existChange == false) 44 break; 45 } 46 } 47 }
以上是关于HW7.17的主要内容,如果未能解决你的问题,请参考以下文章