|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Barefoot on the Moon!
Staff
Premium Member
Join Date: Aug 2002
Location: Northeastern USA
Posts: 13,385
|
I'm having a problem trying to fill a 6x6 matrix in C
Filling it like this is a piece of cake: Code:
0 1 1 1 1 1 -1 0 1 1 1 1 -1 -1 0 1 1 1 -1 -1 -1 0 1 1 -1 -1 -1 -1 0 1 -1 -1 -1 -1 -1 0 Code:
1 1 1 1 1 0 1 1 1 1 0 -1 1 1 1 0 -1 -1 1 1 0 -1 -1 -1 1 0 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 Here's what I have so far, such as it is.
__________________
There are two secrets to staying young, being happy, and achieving success. You have to laugh and find humor every day, and you have to have a dream.
|
|
|
|
|
|
#2 |
|
Barefoot on the Moon!
Staff
Premium Member
Join Date: Aug 2002
Location: Northeastern USA
Posts: 13,385
|
Updated:
I got the diagonal line. Now I just need to figure out how to fill 2 sides. I'm puzzled in this respect. |
|
|
|
|
|
#3 |
|
Member (12 bit)
Join Date: Mar 1999
Location: MN or WI
Posts: 3,017
|
Re: filling a matrix in C
Well, let's look at a for loop:
Code:
for (int i = 0; i < rows; i++){
for (int j = 0; j < cols; j++){
}
}
Code:
| 0 1 2 3 4 5 = j - - - - - - 0| 1 1 1 1 1 0 1| 1 1 1 1 0 -1 2| 1 1 1 0 -1 -1 3| 1 1 0 -1 -1 -1 4| 1 0 -1 -1 -1 -1 5| 0 -1 -1 -1 -1 -1 = i We have a 0 when (5 - j) == i And a -1 when (5 - j) < i
__________________
Paul M. Victorey ------------------ I am not responsible for any problems that may arise as a result of following my advice. This includes, but is not limited to, computer failure, loss of data, nuclear war, famine, boils, no clean laundry, your daughter running off with a biker gang, or armageddon. Take my advice at your own risk. |
|
|
|
|
|
#4 |
|
Barefoot on the Moon!
Staff
Premium Member
Join Date: Aug 2002
Location: Northeastern USA
Posts: 13,385
|
Great! It worked! Thanks a million, Paul Victorey
It was driving me up the wall
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|