| | |
How do I get this pattern?
Thread Solved |
Here's the pattern:
Here's the code I used to get only the first part(the up-side down triangle):
It isn't working, can anybody help?
Java Syntax (Toggle Plain Text)
******* ***** *** * ** *** ***** ********
Here's the code I used to get only the first part(the up-side down triangle):
Java Syntax (Toggle Plain Text)
class hourglass { static void pattern() { for(int j=1;j<=4;j++) { for(int i=1;i<=j;i++) { System.out.print(" "); } for(int i=7;i>j;i--) { System.out.print("*"); } System.out.println(); } } }
It isn't working, can anybody help?
I am using another code to get only the top up-side down triangle:
Java Syntax (Toggle Plain Text)
class hourglass { static void pattern() { for(int j=1;j<=4;j++) { for(int i=1;i<=j;i++) { System.out.print(" "); } for(int i=4;i>=1;i--) { for(int p=1;p<=i;p++) { System.out.print("*"); } } System.out.println(); } } }
•
•
Join Date: Mar 2008
Posts: 76
Reputation:
Solved Threads: 3
java Syntax (Toggle Plain Text)
public class A { public static void main(String[] main) { int length=7; for(int i=length; i>0; i-=2) { for(int j=length-i; j>=0; j--) System.out.print(" "); for(int k=i; k>0; k--) System.out.print("*"); if(i!=1) System.out.println(); } for(int i=-1; i<=length; i+=2) { for(int j=0; j<=length-i; j++) System.out.print(" "); for(int k=0; k<i; k++) System.out.print("*"); System.out.println(); } } }
Last edited by Lensva; Jul 21st, 2009 at 11:26 am.
![]() |
Similar Threads
- Question about string pattern matching (Java)
- Factory Design pattern implementation (C++)
- regExp pattern (Java)
- Orange LED blinks in D2 pattern - Toshiba Laptop A10-S169 (Motherboards, CPUs and RAM)
- Function for a pattern. (C)
- $5 Paypal for guessing the mathematical pattern (Geeks' Lounge)
Other Threads in the Java Forum
- Previous Thread: Storage Help
- Next Thread: Put Comma In Number Format
| Thread Tools | Search this Thread |
6 @param actuate android api applet application arc array arrays automation balls binary bluetooth bold business byte c++ chat class client code codesnippet collections compare component coordinates database defaultmethod detection doctype dragging ebook eclipse educational error file fractal froglogic game givemetehcodez graphics gui guitesting helpwithhomework hql html ide ideas image ingres input integer internet intersect invokingapacheantprogrammatically j2me java javaexcel javaprojects jni jpanel jtextarea julia linux list map method methods mobile mysql netbeans newbie nextline parameter php pong problem program programming project recursion recursive scanner sell server set sms sort sql string sun swing swt terminal threads tree web websites windows





