من یه برنامه ی ماشین حساب می خوام با bascame
فقط چهار عمل اصلی انجام بده
ممنون
فقط چهار عمل اصلی انجام بده
ممنون
1+2*3-4
123*+4-
$regfile = "m32def.dat" $crystal = 8000000 $sim Config Lcdpin = Pin , Db4 = Portc.0 , Db5 = Portc.1 , Db6 = Portc.2 , Db7 = Portc.3 , E = Portc.4 , Rs = Portc.5 Config Lcd = 16 * 2 Config Kbd = Portb , Debounce = 50 , Delay = 255 Dim A As Byte , B As Word , C As Word Dim S As Word , P As Word , T As Word , K As Word Dim O As String * 1 S = 0 : K = 0 : P = 1 : T = 1 Cls Home Main: B = 0 Do A = Getkbd() A = Lookup(a , Read_key) If A > 15 Then Goto Main Select Case A Case Is < 10: B = B * 10 B = B + A Lcd B Wait 1 Case 15: B = B / 10 Shiftcursor Left Lcd " " Shiftcursor Left If B = 0 Then Goto Main Case Is > 9: If A = 10 Then O = "/" If A = 11 Then O = "*" If A = 12 Then O = "+" If A = 13 Then O = "-" Goto 2 End Select Loop 2: Do A = Getkbd() A = Lookup(a , Read_key) If A > 15 Then Goto Main Select Case A Case Is < 10: C = C * 10 C = C + A Lcd C Wait 1 Case 15: C = C / 10 Shiftcursor Left Lcd " " Shiftcursor Left If C = 0 Then Goto Main Case Is > 9: If O = "*" Then S = A * C End If If O = "/" Then S = A / C End If If O = "+" Then S = A + C End If If O = "-" Then S = A - C end if Cls Lcd S Wait 1 A = 0 C = 0 S = 0 Goto Main End Select Loop '------------------------------------------------------------------------------- End 'end program '------------------------------------------------------------------------------- Read_key: Data 1 , 2 , 3 , 10 , 4 , 5 , 6 , 11 , 7 , 8 , 9 , 12 , 13 , 0 , 14 , 15
دیدگاه