Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass {
- public static void main(String args[]) {
- int maxStars = 55;
- int gaps = maxStars/2 - 1;
- for(int i = 1; i < maxStars; i=i+2) {
- for (int p = 0; p <=gaps;p++) {
- System.out.print(" ");
- }
- for (int j = 0; j < i; j++) {
- System.out.print("*");
- }
- for (int p = 0; p <=gaps;p++) {
- System.out.print(" ");
- }
- gaps--;
- System.out.println("");
- }
- gaps = 0;
- for(int i = maxStars; i <= maxStars; i=i-2) {
- for (int p = 0; p <gaps;p++) {
- System.out.print(" ");
- }
- for (int j = 0; j < i; j++) {
- System.out.print("*");
- }
- for (int p = 0; p <gaps;p++) {
- System.out.print(" ");
- }
- gaps++;
- System.out.println("");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement