I'm writing a algorithm which permits to resolve "Hashiwo Kakero" exo, so i defined all bridge as a couple of value example :
bridge1{
x_coordonnate : 5;
y_coorodonnate : 12;
importance : 17;
degre_8: 0;
}
void initialiser_pieces(Piece *piece,int degre,int i , int j){
piece->coordonnees_x = i;
piece->coordonnees_y = j;
piece->degre = degre;
if(degre == 8)
piece->degre_8 = 1;
else
piece->degre_8 = 0;
}
void fonction_check8liaisons(Piece *puzzle[totallignepuzzle],int ligne, int colonne){
int i_local, j_local;
for (i_local = 0; i_local < ligne; i_local ++){
for (j_local = 0; j_local < colonne; j_local ++){
if(&puzzle[i][j].degre == 8){
// can't modify attribute of my matrice , get exception here
puzzle[i][j] = 50;
}
}
}
}
Here is where i define PuzzleDeck
int main(){
...
int totallignepuzzle = 2,totalcolonnepuzzle = 2;
Piece puzzledeck[totallignepuzzle][totalcolonnepuzzle];
// remplissage du puzzle
for(i = 0; i < totallignepuzzle; i++){
for(j = 0; j < totalcolonnepuzzle; j++){
printf("nn Veuillez saisir le degré de la piece de coordonnées (x = %d, y =%d)",i+1,j+1);
scanf("%d",&ledegre);
initialiser_pieces(&puzzledeck[i][j],ledegre,i,j);
}
}
fonction_check8liaisons(&puzzledeck,totallignepuzzle, totalcolonnepuzzle);
}
i will use many function according for all rules and i would like to know how pass a matrix of structure by reference in a function
Could you help me to know how pass a matrix of structure by reference in a function ?
i tried this :
with
but got an exception , could you help me please ?
Aucun commentaire:
Enregistrer un commentaire