本文作者:sukai

鸡兔同笼vb编程(鸡兔同笼问题怎么用vb写程序)

sukai 2023-09-30 91

Private Sub Command1_ClickDim a, b, m, n As Integer #39鸡为a,兔为b,鸡兔总数为m,鸡兔脚数为n For b = 1 To m a = m b If 2 * a + 4 * b = n Then Print quot鸡=quot a quot,兔=quot。

Private Sub Command1_ClickDim h As Integer, f As Integer h = ValInputBoxquot鸡和兔的总头数quot, quot请输入quot, 0f = ValInputBoxquot鸡和兔的总脚数偶数quot, quot请输入quot, 0x = 4 * h f。

#39鸡兔同笼问题 Dim Cock As Integer Dim Rab As Integer For Cock = 0 To 100 Rab = 100 Cock If Cock * 2 + Rab * 4 = 300 Then #39鸡2只脚,兔子4只脚 Print quot其中鸡有quot Cock quot只,兔子有quot。

ChengLi = False Line1m = InputBoxquot输入鸡兔总数quotIf m lt 1 Then MsgBox quot输入错误,请重新输入quotGoTo Line1 End If Line2n = InputBoxquot输入鸡兔总脚数quotIf n lt 1 Or n Mod 2 lt 0 Then MsgBox。

Private Sub Form_ClickDim i, x, y For i = 0 To 35 x = i y = 35 i If x*2 + y*4 = 100 Then Print Formatx,quot鸡有0只quot Formaty,quot,兔有0只quotNext End Sub。

鸡兔同笼vb编程(鸡兔同笼问题怎么用vb写程序)

quot鸡兔同笼quotn = inputboxquot请输入鸡兔总脚数quot,quot鸡兔同笼quot#39数学知识 #39用二元一次方程 #39c + r = m c为鸡的数量,r为兔的数量#392c + 4r = n #39所以c=4mn2 ,r=mc c =。

Text1Text = quot现在有一个装有鸡和兔的笼子,总共有quot x quot个头和 quot y * 2 + z * 4 quot 只脚,请问笼子里的鸡和兔各有多少只quotLabel4ForeColor = vbRed End Sub 效果图 就是这个了我。

在命令按钮里加上以下代码Dim i As Integer, k As Integer, j As Integer Dim x As String j = 0 For i = 1 To 35 For k = 1 To 35 If i * 3 + k * 4 = 100 Then x = x Chr13。

b = Text1Text a If Text2Text = 4 * a + 2 * b Then c = a d = b End If Next If c = 0 And d = 0 Then MsgBox quot其重新输入结果quotElse MsgBox quot兔有quot c quot只,鸡有quot d。

阅读
分享