|
-
January 19th, 2009, 06:23 PM
#6
Re: Nested Loops Triangle Pattern Help
a quicker version:
PHP Code:
public static void main(String[] args) {
int top = 13;
int s = 0;
for (int i=0; i<top*2+1; i++){
s = Math.abs(top-i);
if(s!=0){
for(int j=top; j>s; j--){
System.out.print(" ");
}
for (int j=0; j<s; j++){
System.out.print("* ");
}
System.out.println();
}
}
}
Last edited by Xeel; January 19th, 2009 at 06:30 PM.
Wanna install linux on a vacuum cleaner. Could anyone tell me which distro sucks better?
I had a nightmare last night. I was dreaming that I’m 64-bit and my blanket is 32-bit and I couldn’t cover myself with it, so I’ve spent the whole night freezing. And in the morning I find that my blanket just had fallen off the bed. =S (from: bash.org.ru)
//always looking for job opportunities in AU/NZ/US/CA/Europe :P
willCodeForFood(Arrays.asList("Java","PHP","C++","bash","Assembler","XML","XHTML","CSS","JS","PL/SQL"));
USE [code] TAGS! Read this FAQ if you are new here. If this post was helpful, please rate it!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|