Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lecture4;
- import java.util.Scanner;
- public class NumbersInLine {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- System.out.print("Введите первое число: ");
- int x = scanner.nextInt();
- System.out.print("Введите последнее число: ");
- int y = scanner.nextInt();
- System.out.print("Введите количество чисел в строке: ");
- int n = scanner.nextInt();
- int counter = 0;
- while (counter <= y-x) {
- System.out.printf("%3d ", x+counter);
- counter++;
- if (counter % n == 0) {
- System.out.println();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement