Skip to content

Instantly share code, notes, and snippets.

@Sergaav
Created March 26, 2015 13:45
Show Gist options
  • Save Sergaav/210f0bc688e3bd82e6d2 to your computer and use it in GitHub Desktop.
Save Sergaav/210f0bc688e3bd82e6d2 to your computer and use it in GitHub Desktop.
Figure with *
package com.gmail.sergaav.dz3_4;
import java.util.Scanner;
public class dz3_4 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int i=0;
int j=0;
int n;
System.out.println("Input length:");
n=sc.nextInt()*2;
for(;i< (n-1);){
if(j>=(n/2-Math.abs(n/2-i)))
{
System.out.println();
i++;
j=0;
}
System.out.print("*");
j++;
}
sc.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment