Number Pattern In Java

Posted by Somesh Shinde On Saturday, 30 July 2016 3 comments

if input is::4

4 4 4 4
3 3 3
2 2
1
2 2
3 3 3
4 4 4 4

program::

public class Comment {
public static void main( String arg[]){
int input = 4; //change it accordingly

for(int i=1 ; i<=input ; i++){
for(int j=1 ; j<=input-i+1 ; j++){
System.out.print(input-i+1+" ");
}
System.out.println();
}
for(int k=input-1; k>0 ; k--){
for(int l=2 ; l<=input-k+2 ; l++){
System.out.print(input-k+1+" ");
}
System.out.println();
}
}
}

3 comments:

hitesh kumar said...
This comment has been removed by the author.
hitesh kumar said...
This comment has been removed by the author.
hitesh kumar said...

Above Complete code is copied from Print Star Pattern in Java please remove this code

Post a Comment