Advertisement
sergAccount

Untitled

Aug 2nd, 2020
1,616
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.37 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package com.mycompany.app6;
  7.  
  8. /**
  9.  *
  10.  * @author Admin
  11.  */
  12. public class Test {
  13.    
  14.    
  15.     public static void main(String[] args) {
  16.         /*
  17.         Задача 1
  18.         Создать цикл, который выводит числа от 20 до -20
  19.         кроме числа 0 на экран. (на отдельной строке)
  20.         */
  21.         //
  22.         System.out.println("Вывод информации на разных строках");
  23.         for(int i=20; i>=-20; i--){            
  24.             if(i!=0){
  25.                 System.out.println(i);
  26.             }
  27.         }
  28.         // использование методов System.out.println, System.out.print
  29. //        System.out.println("TEST1");
  30. //        System.out.println("TEST2");
  31. //        
  32. //        System.out.print("TEST3");
  33. //        System.out.print(" ");
  34. //        System.out.print("TEST4");
  35.        
  36.         System.out.println("Вывод информации в одной строке");
  37.         for(int i=20; i>=-20; i--){            
  38.             if(i!=0){
  39.                 System.out.print(" ");
  40.                 System.out.print(i);
  41.             }
  42.         }        
  43.     }
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement