Advertisement
f3n3gz

Untitled

Nov 20th, 2018
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package lecture4;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class NumbersInLine {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. System.out.print("Введите первое число: ");
  10. int x = scanner.nextInt();
  11. System.out.print("Введите последнее число: ");
  12. int y = scanner.nextInt();
  13. System.out.print("Введите количество чисел в строке: ");
  14. int n = scanner.nextInt();
  15.  
  16. int counter = 0;
  17.  
  18. while (counter <= y-x) {
  19. System.out.printf("%3d ", x+counter);
  20. counter++;
  21.  
  22. if (counter % n == 0) {
  23.  
  24. System.out.println();
  25. }
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement