Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  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. int x1=x;
  18.  
  19. while (x1 <= y) {
  20. System.out.printf("%3d ", x1);
  21. counter++;
  22.  
  23. if (counter % n == 0) {
  24.  
  25. System.out.println();
  26. }
  27. x1++;
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement