欺羽吧 关注:26贴子:131
  • 12回复贴,共1
BMI指数
Dim a As Single, b As Single, bmi As Single
a = InputBox("输入身高")
b = InputBox("输入体重")
bmi = b / a ^ 2
If bmi < 18.5 Then
Print bmi; "体重不足"
Else
If bmi < 23 Then
Print bmi; "健康"
Else
If bmi < 25 Then
Print bmi; "超重"
Else
If bmi < 30 Then
Print bmi; "肥胖"
Else
Print bmi; "严重肥胖"
End If
End If
End If
End If
End Sub


1楼2012-04-09 19:44回复
    百钱百鸡
    Dim x As Integer, y As Integer, z As Integer
    z = 0
    Do While z <= 100
    y = 0
    Do While y <= 33
    x = 100 - y - z
    If 5 * x + 3 * y + z / 3 = 100 And x >= 0 Then
    Print "公鸡有", x, "母鸡有", y, "小鸡有", z
    End If
    y = y + 1
    Loop
    z = z + 1
    Loop
    End Sub
    


    2楼2012-04-09 19:45
    回复
      水仙花数
      Dim a As Integer
      Dim b As Integer
      Dim c As Integer
      Dim x As Double
      For a = 1 To 9 Step 1
      For b = 0 To 9 Step 1
      For c = 0 To 9 Step 1
      x = 100 * a + 10 * b + c
      If x = a ^ 3 + b ^ 3 + c ^ 3 Then
      Print x
      End If
      Next c
      Next b
      Next a
      end sub


      3楼2012-04-09 19:46
      回复
        素数判断
        Dim j As Integer
        Dim i As Integer
        Dim w As Integer
        i = InputBox("输入数字")
        For j = 2 To i - 1
        If i Mod j = 0 Then
        w = w + 1
        End If
        Next j
        If w = 0 Then
        Print ("是素数")
        Else
        Print ("不是素数")
        End If
        End Sub


        4楼2012-04-09 19:46
        回复
          斐波那契数列
          Dim a(1 To 20) As Integer, i As Integer, n As Integer
          '生成
          a(1) = 1
          a(2) = 1
          i = 3
          n = InputBox("n=?")
          Do While i <= n
          a(i) = a(i - 1) + a(i - 2)
          i = i + 1
          Loop '输出第n项
          Print n, a(n)


          5楼2012-04-09 19:46
          回复
            选择排序
            Dim a(1 To 50) As Integer, x!
            n = InputBox("输入次数")
            Print "原始数据是:"
            For i = 1 To n
            a(i) = InputBox("第" & i & "个")
            Print a(i);
            Next
            Print
            For j = 1 To n - 1
            min = j
            For i = j + 1 To n
            If a(min) > a(i) Then
            min = i
            End If
            Next i
            x = a(min)
            a(min) = a(j)
            a(j) = x
            Next j For i = 1 To n
            Print a(i);
            Next i
            End Sub


            6楼2012-04-09 19:47
            回复
              冒泡排序
              Dim a(1 To 50) As Integer, i As Integer, t As Integer, j As Integer
              '顺序输入
              i = 1
              Do While i <= 6
              a(i) = InputBox("第" & i & "个")
              Print "输入结果是"; a(i)
              i = i + 1
              Loop
              '冒泡排序
              'a(6)与a(5)比较交换
              x = 1
              Do While x <= 5
              j = 6
              Do
              If a(j) < a(j - 1) Then
              t = a(j)
              a(j) = a(j - 1)
              a(j - 1) = t
              End If
              j = j - 1
              Loop Until j = 1
              x = x + 1
              Loop
              '输出
              Print " 输出结果是:"
              i = 1
              Do While i <= 6
              Print a(i);
              i = i + 1
              Loop
              End Sub
              


              7楼2012-04-09 19:48
              回复
                沉石排序
                Dim a(1 To 500) As Double, i As Double, t As Double, j As Double, n As Double, x As Double
                '顺序输入
                i = 1
                n = InputBox("输入几个数")
                Do While i <= n
                a(i) = InputBox("第" & i & "个")
                Print a(i)
                i = i + 1
                Loop
                '沉石排序
                x = 1
                Do While x < n
                j = 1
                Do While j < n
                If a(j) < a(j + 1) Then
                t = a(j)
                a(j) = a(j + 1)
                a(j + 1) = t
                End If
                j = j + 1
                Loop
                x = x + 1
                Loop
                '输出
                Print " 输出结果是:"
                i = 1
                Do While i <= n
                Print a(i);
                i = i + 1
                Loop
                End Sub


                8楼2012-04-09 19:48
                回复
                  对分查找
                  貌似这个我做错了.跳出循环的好像哪里不对..
                  Dim n As Integer, i As Integer, t As Integer, key As Integer, j As Integer, min As Integer, x As Integer, a(1 To 1000) As Integer, m As Integer
                  n = InputBox("产生n个数")
                  Print "原始数据为"
                  For i = 1 To n
                  Randomize
                  a(i) = Int(Rnd * 30 + 1)
                  Next i
                  For j = 1 To n - 1
                  min = j
                  For i = j + 1 To n
                  If a(min) > a(i) Then
                  min = i
                  End If
                  Next i
                  x = a(min)
                  a(min) = a(j)
                  a(j) = x
                  Next j
                  For i = 1 To n
                  Print a(i);
                  Next i
                  Print
                  t = 1
                  i = 1
                  j = n
                  key = InputBox("输入查找值")
                  m = Int(n / 2)
                  Do While i <= j And a(m) <> key
                  If a(m) < key Then
                  i = m + 1
                  Else
                  j = m - 1
                  End If
                  m = Int((i + j) / 2)
                  t = t + 1
                  Loop
                  If key <> a(m) Then
                  Print "查找值为" & key, "无"
                  Else
                  Print "查找值为" & key, "第" & m & "个", "查找次数为" & t & "次"
                  End If
                  End Sub


                  9楼2012-04-09 19:49
                  回复

                    1. 若一个三位数x=100a+10b+c(a、b、c是各位数),满足a3+b3+c3=x,则x称为水仙花数。找出所有的水仙花数并输出。(153、370、371、407)


                    10楼2012-04-09 19:51
                    回复
                      啊……这是编程……这是遥不可及的编程……


                      IP属地:加拿大11楼2012-04-09 21:24
                      回复
                        这东西没用的


                        IP属地:上海来自掌上百度12楼2012-04-10 09:04
                        回复
                          要考的= =


                          13楼2012-04-10 12:20
                          回复