|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Feb 2007
Messaggi: 543
|
[C] Costruzione matrice 4x5
Ho costruito una matrice 4x4 in questo modo:
float **matr; // matrice 4x4 dinamica matr = new float*[4]; for(int i=0; i<4; i++) { matr[i] = new float[4]; } Vorrei costruire la stessa matrice però 4x5, cioè 4 righe e 5 colonne. Quale parte devo modificare? Grazie a tutti. |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Oct 2007
Città: Padova
Messaggi: 4131
|
Quella dentro il ciclo for
__________________
As long as you are basically literate in programming, you should be able to express any logical relationship you understand. If you don’t understand a logical relationship, you can use the attempt to program it as a means to learn about it. (Chris Crawford) |
|
|
|
|
|
#3 |
|
Senior Member
Iscritto dal: Feb 2007
Messaggi: 543
|
cioè così:
float **matr; // matrice 4x4 dinamica matr = new float*[4]; for(int i=0; i<5; i++) { matr[i] = new float[4]; } |
|
|
|
|
|
#4 | |
|
Member
Iscritto dal: Dec 2007
Messaggi: 121
|
Quote:
float **matr; // matrice 4x4 dinamica matr = new float*[4]; for(int i=0; i<4; i++) { matr[i] = new float[5]; } se eseguissi il codice che hai scritto sopra il programma crasherebbe perchè non esiste matr[4]. |
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 09:25.




















