> 自媒体 > (AI)人工智能 > 【AI来了】Chat AI和文心一言对比
【AI来了】Chat AI和文心一言对比
来源:穷忙工程师
2023-05-25 16:03:12
473
管理

今天让Chat AI写一个程序:用VB编写一个算24点的程序。

不到一分钟就Chat AI就写出来了,而且这程序写得很整洁,有注释,有说明,太厉害了。

感觉一般的码农随时可以被替代了,码农们都要加油了。

不过,同样的要求,文心一言装得也挺像的,也是一会就写出来,不过写出来的程序不知道在做什么,但格式、说明也挺像一回事的,说明文心一言还有很长的路要走,加油!

程序清单1(Chat AI):

以下是用VB编写算24点程序的代码:

Public Class Form1

Dim a As Integer '第1个随机数

Dim b As Integer '第2个随机数

Dim c As Integer '第3个随机数

Dim d As Integer '第4个随机数

'随机生成4个数,并显示在窗体上

Private Sub GenerateNumbers()

Randomize()

a = Int(Rnd() * 9) 1

b = Int(Rnd() * 9) 1

c = Int(Rnd() * 9) 1

d = Int(Rnd() * 9) 1

Label1.Text = a

Label2.Text = b

Label3.Text = c

Label4.Text = d

End Sub

'计算给定的4个数是否能组成24

Private Function Calculate24(ByVal a As Integer, ByVal b As Integer, ByVal c As Integer, ByVal d As Integer) As Boolean

Dim result As Boolean = False

Dim nums() As Integer = {a, b, c, d}

'枚举4个数的所有运算组合,共64种

For i = 0 To 3

For j = 0 To 3

If j i Then

For k = 0 To 3

If k i And k j Then

For l = 0 To 3

If l i And l j And l k Then

'算式1:(a b)*(c d)

result = result Or (nums(i) nums(j)) * (nums(k) nums(l)) = 24

'算式2:(a b-c)*d

result = result Or (nums(i) nums(j) - nums(k)) * nums(l) = 24

'算式3:a/(b-c/d)

result = result Or nums(i) / (nums(j) - nums(k) / nums(l)) = 24

'算式4:a-b-c-d

result = result Or nums(i) - nums(j) - nums(k) - nums(l) = 24

'算式5:(a-b)*(c-d)

result = result Or (nums(i) - nums(j)) * (nums(k) - nums(l)) = 24

End If

Next

End If

Next

End If

Next

Next

Return result

End Function

'生成新的4个数

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

GenerateNumbers()

End Sub

'验证给定的4个数是否能组成24

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

Dim result As Boolean = Calculate24(a, b, c, d)

If result Then

MsgBox("可以组成24")

Else

MsgBox("无法组成24")

End If

End Sub

End Class

程序清单2(文言一心):

Private Sub btnCalculate_Click()

'获取四个数字

Dim num1 As Double

Dim num2 As Double

Dim num3 As Double

Dim num4 As Double

Dim ans As Double

num1 = CDbl(txtNumber1.Text)

num2 = CDbl(txtNumber2.Text)

num3 = CDbl(txtNumber3.Text)

num4 = CDbl(txtNumber4.Text)

'判断是否可以进行计算

If num1 > num2 Then

MsgBox "无法进行计算,数字1大于数字2。"

Exit Sub

End If

If num1 > num3 Then

MsgBox "无法进行计算,数字1大于数字3。"

Exit Sub

End If

If num1 > num4 Then

MsgBox "无法进行计算,数字1大于数字4。"

Exit Sub

End If

If num2 > num3 Then

If num1 <= num3 Then

ans = num1 num2 - num3

Else

ans = num1 - num2 num3

End If

Else

If num1 <= num4 Then

ans = num1 num2 - num4

Else

ans = num1 - num2 num4

End If

End If

'显示结果

MsgBox "计算结果为:" & ans

End Sub

1
点赞
赏礼
赏钱
0
收藏
免责声明:本文仅代表作者个人观点,与本站无关。其原创性以及文中陈述文字和内容未经本网证实,对本文以及其中全部或者 部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。 凡本网注明 “来源:XXX(非本站)”的作品,均转载自其它媒体,转载目的在于传递更多信息,并不代表本网赞同其观点和对 其真实性负责。 如因作品内容、版权和其它问题需要同本网联系的,请在一周内进行,以便我们及时处理。 QQ:617470285 邮箱:617470285@qq.com
关于作者
雪霁(普通会员)
文章
325
关注
0
粉丝
0
点击领取今天的签到奖励!
签到排行

成员 网址收录40328 企业收录2981 印章生成182148 电子证书766 电子名片47 自媒体18209

@2022 All Rights Reserved 浙ICP备19035174号-7
1
0
分享
请选择要切换的马甲:

个人中心

每日签到

我的消息

内容搜索