谁能告诉我:编写一个求二进制数被三除后的余数和商的问题。很急的最好能立刻答复。要是能给出关键部分的程序那最好了

解决方案 »

  1.   

    把除数与被除数都以int型数组存储把除法转化成减法计算
      

  2.   

    Option Explicit
    Private Function Calculate(ByVal Binary As String) As Long
       Dim i As Long, counter As Long, decima As Long _
       , quotient As Long, remainder As Long
       i = Len(Binary): decima = 0
       For counter = 1 To i
           decima = (2 ^ (i - counter)) * Val(Mid(Binary, counter, 1)) + decima
       Next
       quotient = decima / 3
       remainder = decima Mod 3
       Print "Quotient is "; quotient; Chr(10); "Remainder is "; remainder
    End FunctionPrivate Sub Form_click()
       Dim inputer As String
       inputer = InputBox("Input Binary Number", "Input")
       Calculate (inputer)
    End Sub缺陷:只能计算0以上的二进制整数