Advertisement
Guest User

tree

a guest
Aug 14th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. public class Kita3 {
  2. public static void main(String[] args) {
  3. /*
  4. ##*#####*#####* 2 1 5 1 5 1
  5. #***###***###*** 1 3 3 3 3 3
  6. *****#*****#***** 0 5 1 5 1 5
  7. = = =
  8. = = = 2 1 5 1 5 1 - 3 times
  9. = = =
  10. */
  11. int base=5;
  12. int totalTree=3;
  13.  
  14. for (int row=1;row<=base;row+=2){
  15. //for
  16. for (int prefix=(base-row)/2;prefix>0;prefix-=1){
  17. System.out.print(" ");
  18. }
  19. for (int printTree=0;printTree<totalTree;printTree+=1) {
  20. //tree
  21. for (int tree = 0; tree < row; tree += 1) {
  22. System.out.print("*");
  23. }
  24. //space
  25. for (int space = 0; space < base - row + 1; space += 1) {
  26. System.out.print(" ");
  27. }
  28. }
  29. System.out.println();
  30. }
  31. //print the stamp
  32. for (int counter=0;counter<3;counter+=1){
  33. System.out.printf("%2c%c%c%5c%c%5c",' ','=',' ','=',' ','=');
  34. System.out.println();
  35. }
  36.  
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement