参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int []arr = new int[4]; for(int i = 0; i < 4; i++) arr[i] = scanner.nextInt(); System.out.println(Add(arr[0], arr[1]) + "\n" + Add(arr[0], arr[1], arr[2]) + "\n" + Add(arr[0], arr[1], arr[2], arr[3])); } public static int Add(int a, int b) { return a + b; } public static int Add(int a, int b, int c) { return a + b + c; } public static int Add(int a, int b, int c, int d) { return a + b + c + d; } }
0.0分
5 人评分