1 2 100 4 1 3 1 2 样品输出 0 197 3 但我工作的问题要求我 首先要求用户输入最小尺寸的图片 然后他输入他有多少张图片,图片的数量将是行数,每行都有高度和宽度。 如果H和W大于他打印裁剪的最小尺寸,它会更小,他会打印另一个,如果它只是等于他打印接受的最小尺寸,那么对于每一行都会作为输出,我只收到一个输出我写的最后一个输入 样本输入将是: 180 3 640 640 120 300 180 180 样本输出: CROPIT 另一个 接受 谢谢 我的尝试:HelloI saw lots of java problem and I'm a beginner , must of the problem required a test cases so the user can input how many test case he wants to test and then he will input how many line to the first test case , and so onhere is one of the problem I sawInputThe first line contains the number of test cases T. T test cases follow:The first line of each test case contains a number N. The next line contains N integers, denoting the predicted price of WOT shares for the next N days.OutputOutput T lines, containing the maximum profit which can be obtained for the corresponding test case.Constraints1 <= T <= 101 <= N <= 50000All share prices are between 1 and 100000Sample Input335 3 231 2 10041 3 1 2Sample Output01973but the problem I work on ask me to first ask the user to enter the minimum size of picturethen he enter how many pic he has, the number of picture will be the number of lines , each line had hight and width.if the H and W is greater than the minimum size he would print crop it and it it's smaller he would print another and if it's just equal to the minimum size he would print accepted,,, so for each line there would be an output , I just receive one out put for the last input I wrote sample input would be :1803640 640120 300180 180sample output :CROPITANOTHERACCEPTEDThank youWhat I have tried:import java.util.*;public class photo {public static void main(String[] args){Scanner input = new Scanner (System.in);//the minimum size of the picture must be (MxM)int M = input.nextInt();//number of picint K = input.nextInt(); int y=0; int x=0 ; for (int i = 0; i <K; i++) { x=Integer.parseInt(input.next()); y=Integer.parseInt(input.next()); } if (x>M & y>M)System.out.println("CROPIT"); else if(x<M & y<M) System.out.println("ANOTHER"); else System.out.println("ACCEPTED"); } }推荐答案引用:我只收到一个输出,用于我写的最后一个输入...I just receive one output for the last input I wrote...因为if-condition被置于for循环之外。 我建议你在这种情况下使用 ArrayList 。Because if-condition is placed outside for-loop.I would suggest you to use ArrayList in this case.public class photo { public static void main(String[] args) { ArrayList list = new ArrayList<>(); Scanner input = new Scanner(System.in); //the minimum size of the picture must be (MxM) int M = input.nextInt(); //number of pic int K = input.nextInt(); int y = 0; int x = 0; for (int i = 0; i < K; i++) { x = Integer.parseInt(input.next()); y = Integer.parseInt(input.next()); if (x > M & y > M) list.add("CROPIT");// System.out.println("CROPIT"); else if (x < M & y < M) list.add("ANOTHER");// System.out.println("ANOTHER"); else list.add("ACCEPTED");// System.out.println("ACCEPTED"); } for (Object a : list) { System.out.println(a); // print list } }} 这篇关于我在java中编写测试用例时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-19 17:37