Java programming for beginners
前往频道在 Telegram
Learn java programming through quizzes and videos
显示更多未指定国家未指定类别
2 941
订阅者
无数据24 小时
无数据7 天
无数据30 天
帖子存档
This video is very important for freshers, and non CS IT students
Because this will be asked in interview
Kunal Gupta welcome to the group. To learn how to crack coding exams
J Prashanth welcome to the group. To learn how to crack coding exams
Royal Challenge 22 Com In a town, there are N straight roads, with M houses on each road. Each house has a certain number of persons. Neighbours to particular house are next door houses, opposite houses and diagonal houses. 01: 28 DeverMan java DriverMain.java O Write a function to calculate the house with the highest number of neighbours and return the number of neighbours. The input to the function is N and M and the matrix of number representing persons in each house. <>> entryport.c 1'mport java.io.*; 2 mport java.util.*, 3 4 /Your program will be evaluated by this bri Input: 5 Public class DriverMain ( 6. 4-> Number of roads 7-> Number of houses on each road 1234567-> Number of persons in each house on road 1 1234567-> Number of persons in each house on road 1 1234567> Number of persons in each house on road 1 1234567-> Number of persons in each house on road 1 public static void main(String[] args) { Scanner = new Scanner (System.in); 7 8 int M = 3.nextInt (); 9 int Ns.nextInt (); 10 11. Input supplied as: 7 1234567 1234567 1234567 1234567 12 13 int A[] [] = new int [M] [N]; for (int i = 0; i < M; i++) { for (int j = 0; j < N; j++) { A[i][j] =s.nextInt (); 14. 15 Output: 48 16 } 17 18 Explanation: The house located on 2nd road and 6th column of the matrix has neighbouring houses with 5, 5, 5, 6, 6, 7, 7, 7 persons respectively. So their sum le. 5+5+5+6+6+7+7+7=48 and it's the house with maximum number of neighbors. Hence, the output returned is 48.
