c关于鸡兔同笼问题,鸡兔共a只,脚共b只,用循环结构编写程序,要求无解时输出 无解

c关于鸡兔同笼问题,鸡兔共a只,脚共b只,用循环结构编写程序,要求无解时输出 无解,第1张

#include <stdioh>

main()

{

int ji,tu;

for(ji=0;ji<35;ji++)

for(tu=0;tu<35;tu++)

{

if(tu+ji==35&&tu4+ji2==94)

printf("tu=%d ji=%d\n",tu,ji);

}

}

Private Sub Command1_Click()

Dim dblDerta As Single

Dim a As Single, b As Single, c As Single

Dim x1 As String, x2 As String: Dim fbca As String, cca As String

Dim info As String

a = Val(txtAText): b = Val(txtBText): c = Val(txtCText)

txtA = a: txtB = b: txtC = c

infor = ""

Select Case a

Case 0

fbca = "无意义": cca = "无意义": x2 = "无意义"

If b <> 0 Then

x1 = -c / b: infor = "这是一元一次方程 "

Else

If c = 0 Then x1 = "任意值": infor = "这是恒等式 " Else x1 = "不存在": infor = "这个等式不成立"

End If

Case Else

dblDerta = b ^ 2 - 4 c a

fbca = -b / a: cca = c / a

Select Case dblDerta

Case Is > 0

x1 = (-b - Sqr(dblDerta)) / (2 a)

x2 = (-b + Sqr(dblDerta)) / (2 a)

infor = "这个一元二次方程有两个解"

Case 0

x1 = (-b - Sqr(dblDerta)) / (2 a): x2 = x1

infor = "这个一元二次方程有且仅有一个解"

Case Is < 0

x1 = "无意义": x2 = "无意义"

infor = "初中时,此一元二次方程无解"

End Select

End Select

Label1 = "-b /a = " & fbca: Label2 = "c / a = " & cca

Label3 = "x1 = " & x1: Label4 = "x2 = " & x2

Label5 = "Information = " & infor

End Sub

Private Sub Command2_Click()

txtA = 0: txtB = 0: txtC = 0

Label1 = "-b /a = ": Label2 = "c / a = "

Label3 = "x1 = ": Label4 = "x2 = "

Label5 = "Information = "

End Sub

以上就是关于c关于鸡兔同笼问题,鸡兔共a只,脚共b只,用循环结构编写程序,要求无解时输出 无解全部的内容,包括:c关于鸡兔同笼问题,鸡兔共a只,脚共b只,用循环结构编写程序,要求无解时输出 无解、这是我刚做的一个VB的解一元二次方程的程序,因为我不会把i加进去(结果总是没有i),所以默认无解、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/10068306.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-04
下一篇 2023-05-04

发表评论

登录后才能评论

评论列表(0条)

保存