Problème avec le carré magique

cs_Gokuan Messages postés 51 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 17 novembre 2008 - 8 juin 2002 à 14:24
cs_Gokuan Messages postés 51 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 17 novembre 2008 - 8 juin 2002 à 15:06
Salut tout le monde, j'ai encore un problème avec le carré magique, mais bon pour ceux qui ne savent pas exactement ce qui est le bute dans le carré magique:
Vous avez 3 carré sur 3, donc un total de 9, et vous avez 9 bouton(1, 2, 3, 4, 5, 6, 7, 8, 9), mais le 5 doit se trouvé au centre, ensuite vous devez placer les boutons pour que tout toutes les lignes vertical et horizontal donne 15(mais on peut que additioner), puis les 2 diagonal aussi, voilà le bute, mais j'ai justement un problème, moi j'ai créé 9 panel et 9 bitbtn, mais le problème est le suivant, on as mis des labels autours qui donnes la somme qu'il y a sur une ligne vertical, ou horizontal etc..., mais on ne trouve pas comment faire,je veux faire ça, quand on pose le bitbtn1 sur le panel1, 2 ou 3, que le label nous affiche 1, ensuite le bitbtn2 même chose, mais que le label à fait l'addition 1+2=3, donc le label devrait afficher 3, etc...

Merci d'avance!

1 réponse

cs_Gokuan Messages postés 51 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 17 novembre 2008
8 juin 2002 à 15:06
-------------------------------
Réponse au message : Var
B1,b2,b3,resultat :integer ;
Begin
B1 := 0 ;
B2 :=0 ;
B3 :=0 ;
If (bitbtn1.top=panel1.top) and (bitbtn1.left=panel1.left) then
B1 :=1
Else
If (bitbtn2.top=panel1.top) and (bitbtn2.left=panel1.left) then
B1 :=2
Else
If (bitbtn3.top=panel1.top) and (bitbtn3.left=panel1.left) then
B1 :=3
Else
if (bitbtn4.top=panel1.top) and (bitbtn4.left=panel1.left) then
B1 :=4
else
If (bitbtn5.top=panel1.top) and (bitbtn5.left=panel1.left) then
B1 :=5
Else
If (bitbtn6.top=panel1.top) and (bitbtn6.left=panel1.left) then
B1 :=6
Else
If (bitbtn7.top=panel1.top) and (bitbtn7.left=panel1.left) then
B1 :=7
else
If (bitbtn8.top=panel1.top) and (bitbtn8.left=panel1.left) then
B1 :=8
else
If (bitbtn9.top=panel1.top) and (bitbtn9.left=panel1.left) then
B1 :=9 ;

If (bitbtn1.top=panel2.top) and (bitbtn1.left=panel2.left) then
B2 :=1
Else
If (bitbtn2.top=panel2.top) and (bitbtn2.left=panel2.left) then
B2 :=2
Else
If (bitbtn3.top=panel2.top) and (bitbtn3.left=panel2.left) then
B2 :=3
Else
if (bitbtn4.top=panel2.top) and (bitbtn4.left=panel2.left) then
B2 :=4
else
If (bitbtn5.top=panel2.top) and (bitbtn5.left=panel2.left) then
B2 :=5
Else
If (bitbtn6.top=panel2.top) and (bitbtn6.left=panel2.left) then
B2 :=6
Else
If (bitbtn7.top=panel2.top) and (bitbtn7.left=panel2.left) then
B2 :=7
else
If (bitbtn8.top=panel2.top) and (bitbtn8.left=panel2.left) then
B2 :=8
else
If (bitbtn9.top=panel2.top) and (bitbtn9.left=panel2.left) then
B2 :=9 ;

If (bitbtn1.top=panel3.top) and (bitbtn1.left=panel3.left) then
B3:=1
Else
If (bitbtn2.top=panel3.top) and (bitbtn2.left=panel3.left) then
B3 :=2
Else
If (bitbtn3.top=panel3.top) and (bitbtn3.left=panel3.left) then
B3 :=3
Else
if (bitbtn4.top=panel3.top) and (bitbtn4.left=panel3.left) then
B3 :=4
else
If (bitbtn5.top=panel3.top) and (bitbtn5.left=panel3.left) then
B3 :=5
Else
If (bitbtn6.top=panel3.top) and (bitbtn6.left=panel3.left) then
B3 :=6
Else
If (bitbtn7.top=panel3.top) and (bitbtn7.left=panel3.left) then
B3 :=7
else
If (bitbtn8.top=panel3.top) and (bitbtn8.left=panel3.left) then
B3 :=8
else
If (bitbtn9.top=panel3.top) and (bitbtn9.left=panel3.left) then
B3 :=9 ;

Resultat :=b1+b2+b3 ;
Label3.caption :=inttostr(resultat) ;

-------------------------------

Salut tout le monde, j'ai encore un problème avec le carré magique, mais bon pour ceux qui ne savent pas exactement ce qui est le bute dans le carré magique:
Vous avez 3 carré sur 3, donc un total de 9, et vous avez 9 bouton(1, 2, 3, 4, 5, 6, 7, 8, 9), mais le 5 doit se trouvé au centre, ensuite vous devez placer les boutons pour que tout toutes les lignes vertical et horizontal donne 15(mais on peut que additioner), puis les 2 diagonal aussi, voilà le bute, mais j'ai justement un problème, moi j'ai créé 9 panel et 9 bitbtn, mais le problème est le suivant, on as mis des labels autours qui donnes la somme qu'il y a sur une ligne vertical, ou horizontal etc..., mais on ne trouve pas comment faire,je veux faire ça, quand on pose le bitbtn1 sur le panel1, 2 ou 3, que le label nous affiche 1, ensuite le bitbtn2 même chose, mais que le label à fait l'addition 1+2=3, donc le label devrait afficher 3, etc...

Merci d'avance!
0
Rejoignez-nous