Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners what is the logic of this pattern?
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


krishnasachdev
what is the logic of this pattern?
2 Answer(s)      3 years and 6 months ago
Posted in : Java Beginners


                                          1
                                         121  
                                        12321
                                       1234321
                                      123454321

Advertisement
View Answers

July 27, 2011 at 9:29 PM


this is my code.. use string and array:P

public class pattern_ { public static void main(String args[]) {int a[]={1,2,3,4,5}; String S=""; String S1=""; String space=" ";//use a for loop in case of user inputs to create this string int j=5;//space length for(int i=0;i



March 22, 2012 at 2:09 PM


class NumberPattern{ public static void main(String[] args) { int k; for(int i=1;i<=5;i++) { for(int j=5;j>i;j--) { System.out.print(" "); } for(k=1;k<=i;k++) { System.out.print(k); } --k; for(int l=--k;l>=1;l--) { System.out.print(l); } System.out.println(); }

}

}



Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com