12 #include <proto/muimaster.h>
15 #include <proto/utility.h>
17 #include <libraries/mui.h>
25 #include <clib/alib_protos.h>
30 #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
34 #define MADMATRIX_ABS(x) ((x)>0?(x):-(x))
36 #define MADMATRIX_LIGNE(taille,nombre) (int)((nombre-1)/taille)
37 #define MADMATRIX_COLONNE(taille,nombre) (int)((nombre-1)%taille)
38 #define MADMATRIX_NOMBRE(taille,ligne,colonne) ( taille*ligne+colonne+1 )
39 #define MADMATRIX_VOISINS(taille,nb1, nb2) \
40 ((MADMATRIX_ABS(MADMATRIX_LIGNE(taille,nb1)-MADMATRIX_LIGNE(taille,nb2))+\
41 MADMATRIX_ABS(MADMATRIX_COLONNE(taille,nb1)-MADMATRIX_COLONNE(taille,nb2)) ) == 1?1:0)
43 #define MADMATRIX_YOUWIN "You win"
44 #define MADMATRIX_GOODLUCK "Good luck"
46 void Madmatrix_Rotate(struct IClass
*cl
,Object
*obj
, int sens
, double pas
);
47 void Madmatrix_Shake(struct IClass
*cl
,Object
*obj
, int nb
);
48 void Madmatrix_Init(struct Madmatrix_Data
*data
);
49 void Madmatrix_Restart(struct IClass
*cl
,Object
*obj
);
50 void Madmatrix_Tourne(int **tableau
,int ligne
, int colonne
, int sens
);
51 int Madmatrix_Calcul(int **tableau
, int taille
);
54 IPTR
Madmatrix_Dispose(struct IClass
*cl
,Object
*obj
,Msg msg
);
55 IPTR
Madmatrix_New(struct IClass
*cl
,Object
*obj
,Msg msg
);
56 IPTR
Madmatrix_AskMinMax(struct IClass
*cl
,Object
*obj
,struct MUIP_AskMinMax
*msg
);
57 IPTR
Madmatrix_Draw(struct IClass
*cl
,Object
*obj
,struct MUIP_Draw
*msg
);
58 IPTR
Madmatrix_Setup(struct IClass
*cl
,Object
*obj
,struct MUIP_HandleInput
*msg
);
59 IPTR
Madmatrix_Cleanup(struct IClass
*cl
,Object
*obj
,struct MUIP_HandleInput
*msg
);
60 IPTR
Madmatrix_HandleInput(struct IClass
*cl
,Object
*obj
,struct MUIP_HandleInput
*msg
);
63 extern struct GfxBase
*GfxBase
;
64 extern struct IntuitionBase
*IntuitionBase
;
65 extern struct Library
*MUIMasterBase
;
69 #define _between(a,x,b) ((x)>=(a) && (x)<=(b))
70 #define _isinobject(x,y) (_between(_mleft(obj),(x),_mright (obj)) && _between(_mtop(obj) ,(y),_mbottom(obj)))
72 #define MADMATRIX_MAX(a,b) ((a)<(b)?(b):(a))
74 /// ULONG Madmatrix_New(struct IClass *cl,Object *obj,Msg msg)
75 IPTR
Madmatrix_New(struct IClass
*cl
,Object
*obj
,Msg msg
)
77 struct Madmatrix_Data
*data
;
78 /* struct TagItem *tags,*tag;*/
80 if (!(obj
= (Object
*)DoSuperMethodA(cl
,obj
,msg
)))
83 data
= INST_DATA(cl
,obj
);
85 data
->taille
= MADMATRIX_TAILLE_MAX
;
86 data
->ntaille
= MADMATRIX_TAILLE_MAX
;
89 data
->matrice
=(int **)AllocTab(sizeof(int),data
->taille
,data
->taille
);
93 if ( data
->matrice
== NULL
)
100 /// ULONG Madmatrix_Dispose(struct IClass *cl,Object *obj,Msg msg)
101 IPTR
Madmatrix_Dispose(struct IClass
*cl
,Object
*obj
,Msg msg
)
103 struct Madmatrix_Data
*data
= (struct Madmatrix_Data
*)INST_DATA(cl
,obj
);
105 FreeTab((void **)data
->matrice
,data
->taille
);
107 return(DoSuperMethodA(cl
,obj
,msg
));
111 /// ULONG Madmatrix_AskMinMax(struct IClass *cl,Object *obj,struct MUIP_AskMinMax *msg)
112 IPTR
Madmatrix_AskMinMax(struct IClass
*cl
,Object
*obj
,struct MUIP_AskMinMax
*msg
)
114 struct Madmatrix_Data
*data
= INST_DATA(cl
,obj
);
117 data
->font_sx
= _font(obj
)->tf_XSize
;
118 data
->font_sy
= _font(obj
)->tf_YSize
;
120 /*printf("Ask %p %d %d\n",_font(obj),_font(obj)->tf_XSize,_font(obj)->tf_YSize);*/
122 DoSuperMethodA(cl
,obj
,(Msg
)msg
);
124 largeur
= (3*data
->taille
*data
->font_sx
+1);
127 printf("%p\n",_rp(obj));
129 printf("Largeur1 = %d\n",largeur);
130 largeur = MADMATRIX_MAX(largeur,TextLength(_rp(obj),MADMATRIX_YOUWIN,strlen(MADMATRIX_YOUWIN)));
131 printf("Largeur2 = %d\n",largeur);
132 largeur = MADMATRIX_MAX(largeur,TextLength(_rp(obj),MADMATRIX_GOODLUCK,strlen(MADMATRIX_GOODLUCK)));
133 printf("Largeur3 = %d\n",largeur);
135 largeur
= MADMATRIX_MAX(largeur
,data
->font_sx
*strlen(MADMATRIX_YOUWIN
));
136 largeur
= MADMATRIX_MAX(largeur
,data
->font_sx
*strlen(MADMATRIX_GOODLUCK
));
138 msg
->MinMaxInfo
->MinWidth
+= largeur
;
139 msg
->MinMaxInfo
->DefWidth
+= largeur
;
140 msg
->MinMaxInfo
->MaxWidth
+= largeur
;
142 msg
->MinMaxInfo
->MinHeight
+= (2*(data
->taille
+2)*data
->font_sy
); /**/
143 msg
->MinMaxInfo
->DefHeight
+= (2*(data
->taille
+2)*data
->font_sy
);
144 msg
->MinMaxInfo
->MaxHeight
+= (2*(data
->taille
+2)*data
->font_sy
);
151 /// ULONG Madmatrix_Draw(struct IClass *cl,Object *obj,struct MUIP_Draw *msg)
152 IPTR
Madmatrix_Draw(struct IClass
*cl
,Object
*obj
,struct MUIP_Draw
*msg
)
154 struct Madmatrix_Data
*data
= INST_DATA(cl
,obj
);
157 int tf_x
=_rp(obj
)->Font
->tf_XSize
;
158 int tf_y
=_rp(obj
)->Font
->tf_YSize
;
159 int offset_x
, offset_y
, x
,y
;
162 /* clear message zone */
165 RectFill(_rp(obj
),_mleft(obj
),_mtop(obj
)+(2*tf_y
)*(data
->taille
)+1,_mright(obj
),_mbottom(obj
));
171 y
= _mtop(obj
)+(2*tf_y
)*(data
->taille
+1);
174 Text(_rp(obj
),data
->message
,strlen(data
->message
));
179 if ( data
->box
== -1 )
183 Move(_rp(obj
),_mleft(obj
)+(3*tf_x
)*data
->colonne
,_mtop(obj
)+(2*tf_y
)*(data
->ligne
+1)-3*tf_x
/2);
184 Draw(_rp(obj
),_mleft(obj
)+(3*tf_x
)*(data
->colonne
+2),_mtop(obj
)+(2*tf_y
)*(data
->ligne
+1)-3*tf_x
/2);
185 Draw(_rp(obj
),_mleft(obj
)+(3*tf_x
)*(data
->colonne
+2),_mtop(obj
)+(2*tf_y
)*(data
->ligne
+2)+tf_x
/2);
186 Draw(_rp(obj
),_mleft(obj
)+(3*tf_x
)*data
->colonne
,_mtop(obj
)+(2*tf_y
)*(data
->ligne
+2)+tf_x
/2);
187 Draw(_rp(obj
),_mleft(obj
)+(3*tf_x
)*data
->colonne
,_mtop(obj
)+(2*tf_y
)*(data
->ligne
+1)-3*tf_x
/2);
191 if ( data
->box
== 1 )
195 Move(_rp(obj
),_mleft(obj
)+(3*tf_x
)*data
->colonne
,_mtop(obj
)+(2*tf_y
)*(data
->ligne
+1)-3*tf_x
/2);
196 Draw(_rp(obj
),_mleft(obj
)+(3*tf_x
)*(data
->colonne
+2),_mtop(obj
)+(2*tf_y
)*(data
->ligne
+1)-3*tf_x
/2);
197 Draw(_rp(obj
),_mleft(obj
)+(3*tf_x
)*(data
->colonne
+2),_mtop(obj
)+(2*tf_y
)*(data
->ligne
+2)+tf_x
/2);
198 Draw(_rp(obj
),_mleft(obj
)+(3*tf_x
)*data
->colonne
,_mtop(obj
)+(2*tf_y
)*(data
->ligne
+2)+tf_x
/2);
199 Draw(_rp(obj
),_mleft(obj
)+(3*tf_x
)*data
->colonne
,_mtop(obj
)+(2*tf_y
)*(data
->ligne
+1)-3*tf_x
/2);
204 DoSuperMethodA(cl
,obj
,(Msg
)msg
);
206 if (data
->matrice
== NULL
)
212 if ( data
->mouvement
== 0 )
213 RectFill(_rp(obj
),_mleft(obj
),_mtop(obj
),_mright(obj
),_mbottom(obj
));
216 _mleft(obj
)+(3*tf_x
)*data
->colonne
+1,_mtop(obj
)+(2*tf_y
)*(data
->ligne
+1)-3*tf_x
/2+1,
217 _mleft(obj
)+(3*tf_x
)*(data
->colonne
+2)-1,_mtop(obj
)+(2*tf_y
)*(data
->ligne
+2)+tf_x
/2-1
224 offset_x
= (3*tf_x
)*data
->pas
;
225 offset_y
= (2*tf_y
)*data
->pas
;
227 switch ( data
->mouvement
)
231 ligne
= data
->ligne
; colonne
= data
->colonne
;
232 x
= _mleft(obj
)+(3*tf_x
)*colonne
; y
= _mtop(obj
)+(2*tf_y
)*(ligne
+1);
233 sprintf(temp
,"%3d",data
->matrice
[ligne
][colonne
]);
235 Move(_rp(obj
),x
+offset_x
,y
); Text(_rp(obj
),temp
,strlen(temp
));
238 x
= _mleft(obj
)+(3*tf_x
)*colonne
; y
= _mtop(obj
)+(2*tf_y
)*(ligne
+1);
239 sprintf(temp
,"%3d",data
->matrice
[ligne
][colonne
]);
241 Move(_rp(obj
),x
,y
+offset_y
); Text(_rp(obj
),temp
,strlen(temp
));
244 x
= _mleft(obj
)+(3*tf_x
)*colonne
; y
= _mtop(obj
)+(2*tf_y
)*(ligne
+1);
245 sprintf(temp
,"%3d",data
->matrice
[ligne
][colonne
]);
247 Move(_rp(obj
),x
-offset_x
,y
); Text(_rp(obj
),temp
,strlen(temp
));
250 x
= _mleft(obj
)+(3*tf_x
)*colonne
; y
= _mtop(obj
)+(2*tf_y
)*(ligne
+1);
251 sprintf(temp
,"%3d",data
->matrice
[ligne
][colonne
]);
253 Move(_rp(obj
),x
,y
-offset_y
); Text(_rp(obj
),temp
,strlen(temp
));
259 ligne
= data
->ligne
; colonne
= data
->colonne
;
260 x
= _mleft(obj
)+(3*tf_x
)*colonne
; y
= _mtop(obj
)+(2*tf_y
)*(ligne
+1);
261 sprintf(temp
,"%3d",data
->matrice
[ligne
][colonne
]);
262 Move(_rp(obj
),x
,y
+offset_y
); Text(_rp(obj
),temp
,strlen(temp
));
266 x
= _mleft(obj
)+(3*tf_x
)*colonne
; y
= _mtop(obj
)+(2*tf_y
)*(ligne
+1);
267 sprintf(temp
,"%3d",data
->matrice
[ligne
][colonne
]);
269 Move(_rp(obj
),x
-offset_x
,y
); Text(_rp(obj
),temp
,strlen(temp
));
272 x
= _mleft(obj
)+(3*tf_x
)*colonne
; y
= _mtop(obj
)+(2*tf_y
)*(ligne
+1);
273 sprintf(temp
,"%3d",data
->matrice
[ligne
][colonne
]);
275 Move(_rp(obj
),x
,y
-offset_y
); Text(_rp(obj
),temp
,strlen(temp
));
278 x
= _mleft(obj
)+(3*tf_x
)*colonne
; y
= _mtop(obj
)+(2*tf_y
)*(ligne
+1);
279 sprintf(temp
,"%3d",data
->matrice
[ligne
][colonne
]);
281 Move(_rp(obj
),x
+offset_x
,y
); Text(_rp(obj
),temp
,strlen(temp
));
286 for ( ligne
=0;ligne
<data
->taille
; ligne
++)
288 for ( colonne
=0;colonne
<data
->taille
; colonne
++ )
290 x
= _mleft(obj
)+(3*tf_x
)*colonne
;
291 y
= _mtop(obj
)+(2*tf_y
)*(ligne
+1);
292 sprintf(temp
,"%3d",data
->matrice
[ligne
][colonne
]);
295 Text(_rp(obj
),temp
,strlen(temp
));
305 if ( ! data
->shaking
)
307 Move(_rp(obj
),_mleft(obj
)+(3*tf_x
)*data
->colonne
,_mtop(obj
)+(2*tf_y
)*(data
->ligne
+1)-3*tf_x
/2);
308 Draw(_rp(obj
),_mleft(obj
)+(3*tf_x
)*(data
->colonne
+2),_mtop(obj
)+(2*tf_y
)*(data
->ligne
+1)-3*tf_x
/2);
309 Draw(_rp(obj
),_mleft(obj
)+(3*tf_x
)*(data
->colonne
+2),_mtop(obj
)+(2*tf_y
)*(data
->ligne
+2)+tf_x
/2);
310 Draw(_rp(obj
),_mleft(obj
)+(3*tf_x
)*data
->colonne
,_mtop(obj
)+(2*tf_y
)*(data
->ligne
+2)+tf_x
/2);
311 Draw(_rp(obj
),_mleft(obj
)+(3*tf_x
)*data
->colonne
,_mtop(obj
)+(2*tf_y
)*(data
->ligne
+1)-3*tf_x
/2);
320 /// ULONG Madmatrix_Setup(struct IClass *cl,Object *obj,struct MUIP_HandleInput *msg)
321 /* init data & allocate pens */
322 IPTR
Madmatrix_Setup(struct IClass
*cl
,Object
*obj
,struct MUIP_HandleInput
*msg
)
324 if (!(DoSuperMethodA(cl
,obj
,(Msg
)msg
)))
327 MUI_RequestIDCMP(obj
,IDCMP_RAWKEY
);
336 /// ULONG Madmatrix_Set(struct IClass *cl,Object *obj,Msg msg)
337 IPTR
Madmatrix_Set(struct IClass
*cl
,Object
*obj
,struct opSet
*msg
)
339 struct Madmatrix_Data
*data
= INST_DATA(cl
,obj
);
340 struct TagItem
*tags
,*tag
;
342 for (tags
=msg
->ops_AttrList
;(tag
=NextTagItem(&tags
));)
347 case MADMATRIX_TAILLE
:
348 data
->ntaille
=tag
->ti_Data
;
350 case MADMATRIX_GROUPE
:
351 data
->groupe
=(Object
*)tag
->ti_Data
;
356 return(DoSuperMethodA(cl
,obj
,msg
));
360 /// ULONG Madmatrix_Get(struct IClass *cl,Object *obj,Msg msg)
361 IPTR
Madmatrix_Get(struct IClass
*cl
,Object
*obj
,struct opGet
*msg
)
363 struct Madmatrix_Data
*data
= INST_DATA(cl
,obj
);
364 IPTR
*store
= msg
->opg_Storage
;
366 switch (msg
->opg_AttrID
)
368 case MADMATRIX_TAILLE
:
369 *store
= data
->taille
;
373 return(DoSuperMethodA(cl
,obj
,msg
));
377 /// ULONG Madmatrix_HandleInput(struct IClass *cl,Object *obj,struct MUIP_HandleInput *msg)
378 IPTR
Madmatrix_HandleInput(struct IClass
*cl
,Object
*obj
,struct MUIP_HandleInput
*msg
)
380 struct Madmatrix_Data
*data
= INST_DATA(cl
,obj
);
382 if (msg
->muikey
!=MUIKEY_NONE
)
388 MUI_Redraw(obj
,MADF_DRAWUPDATE
);
392 MUI_Redraw(obj
,MADF_DRAWUPDATE
);
397 MUI_Redraw(obj
,MADF_DRAWUPDATE
);
398 if ( data
->ligne
<data
->taille
-2 )
401 MUI_Redraw(obj
,MADF_DRAWUPDATE
);
406 MUI_Redraw(obj
,MADF_DRAWUPDATE
);
407 if ( data
->colonne
<data
->taille
-2 )
410 MUI_Redraw(obj
,MADF_DRAWUPDATE
);
415 MUI_Redraw(obj
,MADF_DRAWUPDATE
);
416 if ( data
->colonne
>0 )
419 MUI_Redraw(obj
,MADF_DRAWUPDATE
);
423 Madmatrix_Rotate(cl
,obj
, -1,PAS
);
424 /*MUI_Redraw(obj,MADF_DRAWUPDATE);*/
427 Madmatrix_Rotate(cl
,obj
, 1, PAS
);
428 /*MUI_Redraw(obj,MADF_DRAWUPDATE);*/
433 if ( msg
->imsg
&& msg
->imsg
->Class
== IDCMP_RAWKEY
)
435 if ( msg
->imsg
->Code
== 24 ) /* 'o' key */
436 Madmatrix_Rotate(cl
,obj
, -1,PAS
);
438 if ( msg
->imsg
->Code
== 25 ) /* 'p' key */
439 Madmatrix_Rotate(cl
,obj
, 1,PAS
);
441 return(DoSuperMethodA(cl
,obj
,(Msg
)msg
));
445 /// ULONG Madmatrix_Cleanup(struct IClass *cl,Object *obj,struct MUIP_HandleInput *msg)
446 IPTR
Madmatrix_Cleanup(struct IClass
*cl
,Object
*obj
,struct MUIP_HandleInput
*msg
)
448 MUI_RejectIDCMP(obj
,IDCMP_RAWKEY
);
450 return(DoSuperMethodA(cl
,obj
,(Msg
)msg
));
454 /// ULONG __attribute__((regparm(3))) Madmatrix_Dispatcher(struct IClass *cl , void *msg,Object *obj )
457 __asm ULONG
Madmatrix_Dispatcher(register __a0
struct IClass
*cl
, register __a2 Object
*obj
, register __a1 Msg msg
)
459 BOOPSI_DISPATCHER(IPTR
, Madmatrix_Dispatcher
, cl
, obj
, msg
)
462 struct Madmatrix_Data
*data
;
464 data
= INST_DATA(cl
,obj
);
466 switch (msg
->MethodID
)
468 case OM_NEW
: return(Madmatrix_New(cl
,obj
,(APTR
)msg
));
469 case OM_DISPOSE
: return(Madmatrix_Dispose(cl
,obj
,(APTR
)msg
));
470 case OM_SET
: return(Madmatrix_Set(cl
,obj
,(APTR
)msg
));
471 case OM_GET
: return(Madmatrix_Get(cl
,obj
,(APTR
)msg
));
472 case MUIM_AskMinMax
: return(Madmatrix_AskMinMax (cl
,obj
,(struct MUIP_AskMinMax
*)msg
));
473 case MUIM_Draw
: return(Madmatrix_Draw (cl
,obj
,(struct MUIP_Draw
*)msg
));
474 case MUIM_HandleInput
: return(Madmatrix_HandleInput(cl
,obj
,(struct MUIP_HandleInput
*)msg
));
475 case MUIM_Setup
: return(Madmatrix_Setup (cl
,obj
,(struct MUIP_HandleInput
*)msg
));
476 case MUIM_Cleanup
: return(Madmatrix_Cleanup (cl
,obj
,(struct MUIP_HandleInput
*)msg
));
477 case MADMATRIX_SHAKE
: Madmatrix_Shake(cl
,obj
,data
->taille
*data
->taille
-data
->taille
+1); return(TRUE
);
478 case MADMATRIX_RESTART
: Madmatrix_Restart(cl
,obj
); return(TRUE
);
483 return(DoSuperMethodA(cl
,obj
,(Msg
)msg
));
486 BOOPSI_DISPATCHER_END
494 /// void Madmatrix_Rotate(struct IClass *cl,Object *obj, int sens, double pas)
495 /* init data & allocate pens */
496 void Madmatrix_Rotate(struct IClass
*cl
,Object
*obj
, int sens
, double pas
)
498 struct Madmatrix_Data
*data
= INST_DATA(cl
,obj
);
500 data
->mouvement
=sens
;
501 for ( data
->pas
=0; data
->pas
<= 1; data
->pas
+=pas
)
504 MUI_Redraw(obj
,MADF_DRAWUPDATE
);
507 Madmatrix_Tourne(data
->matrice
, data
->ligne
, data
->colonne
, sens
);
509 if ( Madmatrix_Calcul(data
->matrice
,data
->taille
) == data
->taille
*data
->taille
)
510 data
->message
="You win !";
511 Madmatrix_Tourne(data
->matrice
, data
->ligne
, data
->colonne
, -sens
);
514 MUI_Redraw(obj
,MADF_DRAWUPDATE
);
517 Madmatrix_Tourne(data
->matrice
, data
->ligne
, data
->colonne
, sens
);
521 /// void Madmatrix_Shake(struct IClass *cl,Object *obj, int nb)
522 void Madmatrix_Shake(struct IClass
*cl
,Object
*obj
, int nb
)
524 struct Madmatrix_Data
*data
= INST_DATA(cl
,obj
);
528 MUI_Redraw(obj
,MADF_DRAWUPDATE
);
532 for ( cpt
=0; cpt
<nb
; cpt
++ )
534 data
->ligne
= rand()%(data
->taille
-1);
535 data
->colonne
= rand()%(data
->taille
-1);
538 Madmatrix_Rotate(cl
,obj
,sens
,3*PAS
);
547 data
->message
=MADMATRIX_GOODLUCK
;
548 MUI_Redraw(obj
,MADF_DRAWUPDATE
);
553 /// void Madmatrix_Init(struct Madmatrix_Data *data)
554 void Madmatrix_Init(struct Madmatrix_Data
*data
)
556 int ligne
, colonne
,nb
=1;
558 for ( ligne
=0; ligne
<data
->taille
; ligne
++ )
559 for ( colonne
=0; colonne
<data
->taille
; colonne
++ )
560 data
->matrice
[ligne
][colonne
]=nb
++;
571 /// void Madmatrix_Restart(struct IClass *cl,Object *obj)
572 void Madmatrix_Restart(struct IClass
*cl
,Object
*obj
)
574 struct Madmatrix_Data
*data
= INST_DATA(cl
,obj
);
577 if ( data
->ntaille
> MADMATRIX_TAILLE_MAX
)
578 data
->ntaille
= MADMATRIX_TAILLE_MAX
;
580 if ( data
->ntaille
< 3 )
583 if ( data
->taille
!= data
->ntaille
)
587 if (DoMethod(data
->groupe
,MUIM_Group_InitChange
))
589 FreeTab((void **)data
->matrice
,data
->taille
);
590 data
->matrice
= NULL
;
592 DoMethod(data
->groupe
,OM_REMMEMBER
,obj
);
593 data
->taille
=data
->ntaille
;
594 DoMethod(data
->groupe
,OM_ADDMEMBER
,obj
);
596 DoMethod(data
->groupe
,MUIM_Group_ExitChange
);
601 FreeTab((void **)data
->matrice
,data
->taille
);
602 data
->matrice
= NULL
;
603 data
->taille
=data
->ntaille
;
607 data
->matrice
=(int **)AllocTab(sizeof(int),data
->taille
,data
->taille
);
610 Madmatrix_Init(data
);
614 MUI_Redraw(obj
,MADF_DRAWOBJECT
);
619 /// void Madmatrix_Tourne(int **tableau,int ligne, int colonne, int sens )
620 void Madmatrix_Tourne(int **tableau
,int ligne
, int colonne
, int sens
)
622 int temp
=tableau
[ligne
][colonne
];
626 tableau
[ligne
][colonne
] = tableau
[ligne
+1 ][colonne
];
627 tableau
[ligne
+1 ][colonne
] = tableau
[ligne
+1 ][colonne
+1 ];
628 tableau
[ligne
+1 ][colonne
+1 ] = tableau
[ligne
][colonne
+1 ];
629 tableau
[ligne
][colonne
+1 ] = temp
;
633 tableau
[ligne
][colonne
] = tableau
[ligne
][colonne
+1 ];
634 tableau
[ligne
][colonne
+1 ] = tableau
[ligne
+1 ][colonne
+1 ];
635 tableau
[ligne
+1 ][colonne
+1 ] = tableau
[ligne
+1 ][colonne
];
636 tableau
[ligne
+1 ][colonne
] = temp
;
644 /// int Madmatrix_Calcul(int **tableau, int taille)
645 int Madmatrix_Calcul(int **tableau
, int taille
)
651 for ( ligne
=0; ligne
<taille
; ligne
++ )
652 for ( colonne
=0; colonne
<taille
; colonne
++ )
654 if ( tableau
[ligne
][colonne
] == MADMATRIX_NOMBRE(taille
,ligne
,colonne
) )