voila je me sui amuser a faire un calculateur de PGCD le voici
Code : Tout sélectionner
;- Window Constants
;
Enumeration
#Window_0
EndEnumeration
;- Gadget Constants
;
Enumeration
#String_0
#String_1
#String_2
#Button_0
#Listview_1
#Text_0
#Frame3D_0
#Frame3D_2
#Frame3D_3
EndEnumeration
If OpenWindow(#Window_0, 216, 5, 300, 386, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "calculateur PGCD ")
If CreateGadgetList(WindowID())
StringGadget(#String_0, 20, 30, 80, 20, "")
StringGadget(#String_1, 140, 30, 80, 20, "")
StringGadget(#String_2, 60, 270, 100, 20, "",#PB_String_ReadOnly )
ButtonGadget(#Button_0, 60, 310, 100, 30, "CALCULER")
ListViewGadget(#Listview_1, 10, 70, 280, 170)
TextGadget(#Text_0, 10, 360, 220, 20, "fabriqué par le petit scaraber", #PB_Text_Center | #PB_Text_Border)
Frame3DGadget(#Frame3D_0, 50, 250, 120, 50, "PGCD")
Frame3DGadget(#Frame3D_2, 10, 10, 100, 50, "grand nombre")
Frame3DGadget(#Frame3D_3, 130, 10, 100, 50, "petit nombre")
EndIf
EndIf
Repeat
Event = WindowEvent()
If Event = #PB_EventGadget
WaitWindowEvent()
If EventGadgetID() = #Button_0
a=Val(GetGadgetText(#String_0))
b=Val(GetGadgetText(#String_1))
Dim R.f(30)
For x=1 To 20
C.f=a/b
AddGadgetItem(#Listview_1, Position,"on trouve combien de B=A (nombredeB=A/B)" ):position=position+1
AddGadgetItem(#Listview_1, Position,Str(C)+"="+Str(a)+"/"+Str(b) ):position=position+1
F=Int(C)
AddGadgetItem(#Listview_1, Position,"on rend le nombrer de B en nommbre non décimale" ):position=position+1
AddGadgetItem(#Listview_1, Position, Str(F)):position=position+1
R(x)=a-(b*F)
AddGadgetItem(#Listview_1, Position,"on calcul le reste" ):position=position+1
AddGadgetItem(#Listview_1, Position,Str(R(x))+"="+Str(a)+"-"+Str(b)+"*"+Str(F) ):position=position+1
a=b
b=R(x)
AddGadgetItem(#Listview_1, Position, "on met le reste dans B et on met B en A"):position=position+1
If R(x)=0
PGCD=R(x-1)
If R(x-1)=0
PGCD=1
EndIf
SetGadgetText(#String_2,Str(pgcd))
Goto fin
EndIf
Next x
EndIf
EndIf
fin:
Until WindowEvent()=#PB_Event_CloseWindow
++