View Single Post
Old 07-23-2012, 10:35 PM   PM User | #1
celticpride678
New to the CF scene

 
Join Date: Jul 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
celticpride678 is an unknown quantity at this point
Print square of numbers with positions alternating

Hello. I'm having some troubles with the following problem:

Quote:
Write a method called printSquare that takes in two integer parameters, a min and a max, and prints the numbers in the range from min to max inclusive in a square pattern. The square pattern is easier to understand by example than by explanation, so take a look at the sample method calls and their resulting console output in the table below.

Each line of the square consists of a circular sequence of increasing integers between min and max. Each line prints a different permutation of this sequence. The first line begins with min, the second line begins with min + 1, and so on. When the sequence in any line reaches max, it wraps around back to min.

You may assume the caller of the method will pass a min and a max parameter such that min is less than or equal to max.
This is the code I have so far:

Code:
public*static*void*printSquare(int*min,int*max){
    for(int*lines=1;lines<=min;lines++){
        for(int*x=min;x<=max;x++){
            System.out.print(x);
        }
        System.out.println();
        min+=1;
    }
}
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2012-07-23 at 5.34.49 PM.png
Views:	29
Size:	17.9 KB
ID:	11383  
celticpride678 is offline   Reply With Quote