Created
May 23, 2018 14:07
-
-
Save sagardere/af49eb966b445ca53019a44883565ff5 to your computer and use it in GitHub Desktop.
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
import java.util.Scanner; | |
public class pattern { | |
public static void printTriagle(int n) | |
{ | |
int temp = n; | |
for(int i=0;i<n;i++) { | |
for(int j=0;j<n*2;j++) { | |
if(i==0) { | |
System.out.print(n); | |
} else if ((j<n-i) || (j>=temp+(i*2))) { | |
System.out.print(temp); | |
} else { | |
System.out.print("*"); | |
} | |
} | |
temp--; | |
System.out.println(""); | |
} | |
} | |
public static void main(String[] args) { | |
pattern obj=new pattern(); | |
Scanner sc=new Scanner(System.in); | |
System.out.println("Enter the value of n : "); | |
int n = sc.nextInt(); | |
obj.printTriagle(n); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment