Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Triangle {
- public static void main(String[] args) {
- Scanner scanner=new Scanner(System.in);
- int n=Integer.parseInt(scanner.nextLine());
- int p=1;
- int m=n;
- int q=n;
- int c=n;
- int en=1;
- int z=0;
- int s=n;
- System.out.println(repeatStr("#",4*n+1));
- z++;//full row
- for (int i = 0; i <n/2 ; i++) {
- System.out.print(repeatStr(".",p));
- System.out.print(repeatStr("#",2*m-1));
- System.out.print(repeatStr(" ",en));
- System.out.print(repeatStr("#",2*m-1));
- System.out.println(repeatStr(".",p));
- p++;
- en=en+2;
- m--;
- z++;
- }
- en=en-2;
- System.out.print(repeatStr(".",z));
- System.out.print(repeatStr("#",2*m-1));
- System.out.print(repeatStr(" ",(((en+2)-3))/2));
- System.out.print("(@)");
- System.out.print(repeatStr(" ",(((en+2)-3))/2));
- System.out.print(repeatStr("#",2*m-1));
- System.out.println(repeatStr(".",z));
- z++;
- int v=en;
- for (int d=0;d<n-(s/2+1);d++)
- {
- System.out.print(repeatStr(".",z));
- System.out.print(repeatStr("#",v-1));
- System.out.print(repeatStr(" ",((4*n+1)-(2*z+2*(v-1)))));
- System.out.print(repeatStr("#",v-1));
- System.out.println(repeatStr(".",z));
- z++;
- v=v-2;}
- for(int j=0;j<q;j++)
- {
- System.out.print(repeatStr(".",c+1));
- System.out.print(repeatStr("#",2*n-1));
- System.out.println(repeatStr(".",c+1));
- n=n-1;
- c=c+1;}
- }
- static String repeatStr(String str, int count ){
- String text="";
- {
- for (int j = 0; j <count ; j++) {
- text=text+str;
- }
- }
- return text;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement