编程题:14
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int A = scanner.nextInt();
int B = scanner.nextInt();
int sum = 0;
int count = 0;
for (int i = A; i <= B; i++) {
System.out.printf("%5d", i);
sum += i;
count++;
if (count % 5 == 0) {
System.out.println();
}
}
if (count % 5 != 0) {
System.out.println();
}
System.out.println("Sum = " + sum);
}
}
浙公网安备 33010602011771号