Can anyone help me??

Aici puteti sta la un pahar de vorba cu ceilalti membri despre orice subiect.

Can anyone help me??

Mesajde rolandbaker » 20 Apr 2017, 16:10

So the output is something like this?

1 +1 +1 +1 +1 +1 +1 +1 +1 +1 0
2 +1 +1 +1 +1 +1 +1 +1 +1 0 -1
3 +1 +1 +1 +1 +1 +1 +1 0 -1 -1
4 +1 +1 +1 +1 +1 +1 0 -1 -1 -1
5 +1 +1 +1 +1 +1 0 -1 -1 -1 -1
6 +1 +1 +1 +1 0 -1 -1 -1 -1 -1
7 +1 +1 +1 0 -1 -1 -1 -1 -1 -1
8 +1 +1 0 -1 -1 -1 -1 -1 -1 -1
9 +1 0 -1 -1 -1 -1 -1 -1 -1 -1
10 0 -1 -1 -1 -1 -1 -1 -1 -1 -1

You can find a pattern that will allow you to decide what value to output using nested for loops, where the outer loop controls the row, and the inner loop controls the column.

In the case above, the matrix has 10 rows and 10 columns. In row 1, it's all +1 except column 10, which has a zero for the diagonal. In row 2, it's +1 up to column 9 which gets a 0 for the diagonal. In row 3, it's +1 up to column 8 which gets a 0 for the diagonal.

There's a pattern here that can be used to output the 0 for the diagonal.
Row + Col on diagonal 1 + 10
Row + Col on diagonal 2 + 9
Row + Col on diagonal 3 + 8
and so on....

Does that make any sense? The +1 and -1 follows on from this.

Thanks.
I didn't find the right solution from the internet.
References:
- http://www.cplusplus.com/forum/general/213460/
- Fire Protection Service Video Examples
rolandbaker
Junior
Junior
 
Mesaje: 29
Membru din: 25 Feb 2017, 15:38
Judet: Vaslui

Înapoi la Discutii

Cine este conectat

Utilizatorii ce navighează pe acest forum: Niciun utilizator înregistrat şi 2 vizitatori

cron