KiKi参加了语文、数学、外语的考试,请帮他判断三科中的最高分。从键盘任意输入三个整数表示的分数,编程判断其中的最高分。
数据范围:
import java.util.Arrays; import java.util.Scanner; /** * @Title: 最高分 * @Remark: KiKi参加了语文、数学、外语的考试,请帮他判断三科中的最高分。从键盘任意输入三个整数表示的分数,编程判断其中的最高分。 * @Author: ijunfu * @Version: 1.0.0 * @Date: 2022-03-19 */ public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); Integer[] scores = new Integer[3]; for(int i=0; i<3; i++) { scores[i] = in.nextInt(); } Arrays.sort(scores, (a, b) -> b - a); System.out.println(scores[0]); in.close(); } }
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { ArrayList<Integer> s = new ArrayList<Integer>(); for (int i = 0; i < 3; i++) { s.add(scanner.nextInt()); } System.out.println(Collections.max(s)); } scanner.close(); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { String str = sc.nextLine(); MaxGrade m = new MaxGrade(); System.out.println(m.maxGrade(str)); } } } class MaxGrade { public Integer maxGrade(String str) { String[] grade = str.split(" "); Integer maxgrade = 0 ; Integer grade1 = Integer.parseInt(grade[0]); Integer grade2 = Integer.parseInt(grade[1]); Integer grade3 = Integer.parseInt(grade[2]); if(grade1>=grade2){ maxgrade = grade1; } else{ maxgrade = grade2; } if(maxgrade <= grade3) { maxgrade = grade3; } return maxgrade; } }
import java.util.Scanner; import java.util.ArrayList; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); ArrayList<Integer> nums = new ArrayList<>(); int num; while (input.hasNext()) { for (int i = 0; i < 3; i++) { num = input.nextInt(); nums.add(num); } MaxNumber maxNumber = new MaxNumber(nums); System.out.println(maxNumber.getMaxNumber()); nums.clear(); // 每次运算完毕,清空nums } } } class MaxNumber { ArrayList<Integer> nums = new ArrayList<>(); public MaxNumber(ArrayList<Integer> nums) { this.nums = nums; } protected int getMaxNumber() { int maxNumber = Integer.MIN_VALUE; for (Integer num : this.nums) { if (num > maxNumber) { maxNumber = num; } } return maxNumber; } }
import java.util.Scanner; public class Main { public static void partitaion(int[] array , int left , int right) { int l = left; int r = right; int ref = array[l]; while (l<r){ while (l<r&&array[r]<=ref){ r -- ; } if(array[r]>=ref){ exchange(array,r,l); } while (l<r&&array[l]>=ref){ l ++ ; } if(array[l]<=ref){ exchange(array,r,l); } } if(l>left){ partitaion(array,left,l-1); } if(r<right){ partitaion(array,r+1,right); } } public static void exchange(int[] array,int a,int b) { int temp = array[a]; array[a] = array[b]; array[b] = temp; } public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNextLine()) { String[] s = scanner.nextLine().split(" "); int[] array = new int[s.length]; for (int i = 0; i < s.length; i++) { array[i] = Integer.parseInt(s[i]); } partitaion(array, 0, s.length - 1); System.out.println(array[0]); } } }
import java.util.*; public class Main { public static void main(String [] args) { Scanner sc=new Scanner(System.in); int[] arr = new int[3]; while(sc.hasNext()){ for(int i=0;i<=arr.length-1;i++){ arr[i] = sc.nextInt(); } Arrays.sort(arr); System.out.println(arr[2]); } } }
import java.util.*; public class Main { public static void main(String [] args) { Scanner sc=new Scanner(System.in); while(sc.hasNextInt()) { int a=sc.nextInt(); int b=sc.nextInt(); int c=sc.nextInt(); int [] arr={a,b,c}; Arrays.sort(arr); System.out.println(arr[2]); } } }