Last active
September 13, 2015 17:45
-
-
Save Pyroarsonist/d3bb953a54a7e1dc8919 to your computer and use it in GitHub Desktop.
Stars
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package lvl2cc; | |
| import java.util.Scanner; | |
| public class Main { public static void main(String[] args) { | |
| Scanner sc = new Scanner(System.in); | |
| int x=2; | |
| int y=2; | |
| boolean z=false; | |
| System.out.print("Input maximum of stars: "); | |
| int k=sc.nextInt(); | |
| k++; | |
| do { | |
| System.out.print("*"); | |
| if (x==y&&y<k&&z==false){ | |
| System.out.println(); | |
| x=1; | |
| y++; | |
| } | |
| if (y==k){ | |
| z=true; | |
| } | |
| if (x==y&&y>0&&z==true){ | |
| System.out.println(); | |
| x=1; | |
| y--; | |
| } | |
| x++; | |
| } while (y!=1); | |
| sc.close(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment