I've tried many ways to do this, but can't seem to find out how to make patters such as these in a C program. I've tried most things I've learned about C so far, but still no cigar. Last time I came here I got outstanding help from you guys, so thanks very much for that! If any more information is needed then feel free to ask for it. I have the rest of the program but it is quite long now so I thought I'd simplify it a bit.
Here's the basics of my program:
1. User see's options of patterns.
2. User chooses an option.
3. User chooses a size (more details on this below).
4. The correct pattern & size is printed.
Size can be [ 2 - 9 ]
Here are what the functions should look like after printing.
Pattern One:
if size is 5:
1 * * * *
5 2 * * *
5 5 3 * *
5 5 5 4 *
5 5 5 5 5
if the size is 6:
1 * * * * *
6 2 * * * *
6 6 3 * * *
6 6 6 4 * *
6 6 6 6 5 *
6 6 6 6 6 6
Pattern Two:
(random numbers within the range 0 to size, inclusive)
if size is 5:
*********
* 0 4 3 *
* 1 2 5 *
* 3 0 1 *
*********
if size is 6:
***********
* 3 6 2 0 *
* 5 3 0 2 *
* 4 5 3 1 *
* 1 2 0 3 *
***********
Pattern Three:
The printed pattern does not include the - 's. I put those in because it is all aligned to the right, and this forum does not allow me to use spaces like that. However I just saw the Align Right button.... oh well you know what I was getting at.
if size is 5:
and the first number is 0:
--- 0 1 2 3 4
----- 5 6 7 8
------- 9 0 1
--------- 2 3
----------- 4
f size is 5:
--- 5 6 7 8 9
----- 0 1 2 3
------- 4 5 6
--------- 7 8
----------- 9
and the first number is 5:
The first number in the pattern is a random integer between 0 and 9 inclusive. All numbers in the pattern are integers within the same range. Notice that they are consecutive integers as you read the pattern one row at a time, left to right, and when you get to ten, the number changes back to 0.
Thanks for any help, this one has got me stumped.