Advertisement
Vidinov

PrintTriangle2

Feb 19th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PrintTriangle2
  4. {
  5. public static void main(String[] args)
  6. {
  7. Scanner in = new Scanner(System.in);
  8. System.out.println("Vuvedi razmer na triugulnik:");
  9. int size = in.nextInt();
  10. if (size<=0){
  11. System.out.println("Vuvedi polojitelno chislo");
  12. size=in.nextInt();
  13. }
  14. int row = 1;
  15. int col = size;
  16.  
  17. for (int i = 0; i < size; i++) {
  18. for (int k=0; k<row;k++){
  19. System.out.print(" ");
  20. }
  21. for (int j = 0; j < col; j++) {
  22. System.out.print("# ");
  23. }
  24. System.out.println();
  25. row++;
  26. col--;
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement