| | |
Pattern Program help
![]() |
Ok, I need help on a for loop nested program using for loops, I'm trying to use a patten that goes like this:
123456
12345
1234
123
12
1
but when I try it, it goes like this:
654321
65432
6543
654
65
6
This is my program:
public class Patterns{
public static void main (String [] args) {
//set up for the rows
for(int row = 1 ; row <= 6; row++){
for (int num = 6; num >= row; num--){
System.out.print(num);
}
System.out.println();
}
}
}
Can anybody help please? thanks
123456
12345
1234
123
12
1
but when I try it, it goes like this:
654321
65432
6543
654
65
6
This is my program:
public class Patterns{
public static void main (String [] args) {
//set up for the rows
for(int row = 1 ; row <= 6; row++){
for (int num = 6; num >= row; num--){
System.out.print(num);
}
System.out.println();
}
}
}
Can anybody help please? thanks
Ok I solved the last program, but I need on this one, I have no clue:
Ok, I need help on a for loop nested program using for loops, I'm trying to use a patten that goes like this:
123456
12345
1234
123
12
1
but when I try it, it goes like this:
123456
12345
1234
123
12
1
This is my program:
public class Patterns{
public static void main (String [] args) {
//set up for the rows
for(int row = 7 ; row > 1; row--){
for (int num = 1; num < row; num++){
System.out.print(num);
}
System.out.println();
}
}
}
Can anybody help please? thanks
Ok, I need help on a for loop nested program using for loops, I'm trying to use a patten that goes like this:
123456
12345
1234
123
12
1
but when I try it, it goes like this:
123456
12345
1234
123
12
1
This is my program:
public class Patterns{
public static void main (String [] args) {
//set up for the rows
for(int row = 7 ; row > 1; row--){
for (int num = 1; num < row; num++){
System.out.print(num);
}
System.out.println();
}
}
}
Can anybody help please? thanks
•
•
Join Date: Apr 2006
Posts: 164
Reputation:
Solved Threads: 10
if you write the problem using code bbcode, it looks better...
you want something like
There are different ways to solve this problem.
I would used a for loop to count how many empty spaces (" ") I need to print before I put the number. So that would increase from 0 to 5.. This way, it actually needed three for loops, and one counter based on what it would count how many space is needed.
Code would look something like:
you want something like
Java Syntax (Toggle Plain Text)
123456 12345 1234 123 12 1
There are different ways to solve this problem.
I would used a for loop to count how many empty spaces (" ") I need to print before I put the number. So that would increase from 0 to 5.. This way, it actually needed three for loops, and one counter based on what it would count how many space is needed.
Code would look something like:
Java Syntax (Toggle Plain Text)
int counter=0; firstLoop: for() { secondLoop:for() { thirdLoop:for(0->counter){ System.out.print(" "); } System.out.print(num); } System.out.println(); counter++; }
Last edited by orko; Sep 28th, 2007 at 11:18 am.
A Perfect World
•
•
Join Date: Jul 2009
Posts: 1
Reputation:
Solved Threads: 0
[COLOR="Green"]this:
123456
12345
1234
123
12
1
This is my program:
public class Patterns{
public static void main (String [] args) {
//set up for the rows
for(int row = 6 ; row >= 1; row++){
for (int num = 1; num <= row; num++){
System.out.print(num);
}
System.out.println();
}
}
}
where u frm?????
my id:chrsmnsn@gmail.com
123456
12345
1234
123
12
1
This is my program:
public class Patterns{
public static void main (String [] args) {
//set up for the rows
for(int row = 6 ; row >= 1; row++){
for (int num = 1; num <= row; num++){
System.out.print(num);
}
System.out.println();
}
}
}
where u frm?????
my id:chrsmnsn@gmail.com
Last edited by audioslave; Jul 26th, 2009 at 12:26 am.
•
•
•
•
[COLOR="Green"]this:
123456
12345
1234
123
12
1
This is my program:
public class Patterns{
public static void main (String [] args) {
//set up for the rows
for(int row = 6 ; row >= 1; row++){
for (int num = 1; num <= row; num++){
System.out.print(num);
}
System.out.println();
}
}
}
where u frm?????
my id:chrsmnsn@gmail.com
???? This post is years old, do u need help or you just wondering where I'm from?
![]() |
Similar Threads
- Question about string pattern matching (Java)
- Design pattern for encode/decode modules (C++)
- C++ Fibonacci program help (C++)
- have some problems with pattern match hope you can help!! (Perl)
- how to find the string pattern? (Assembly)
- Help with Java program writing (Java)
- PLEASE HELP about Using C# to add an executable file to my program! (C#)
Other Threads in the Java Forum
- Previous Thread: help
- Next Thread: Help with JMF? (Playing audio file)
| Thread Tools | Search this Thread |
2dgraphics account android api apple applet application arguments array arrays automation banking binary binarytree bluetooth chat chatprogramusingobjects class client code color component count database derby design eclipse eclipsedevelopment encryption error fractal game givemetehcodez graphics gridlayout gui html ide if_statement image input integer interface j2me java javadesktopapplications javaprojects jlabel jni jpanel julia keyword linux list loop macintosh map method methods midlethttpconnection mobile netbeans newbie nullpointerexception object open-source os problem producer program programming project projectideas property read recursion reference replaysolutions ria scanner search server set size sms sort sourcelabs splash sql stop string swing testautomation threads transforms tree ui unicode validation windows





