高中学业水平考试——信息技术 ——程序改错

程序改错 1、陈婷植树:陈婷今年 17 岁,植了 3 棵树。以后每年多植一棵,问她到多少岁时才能累计种到或超过 100 棵树?

程序改错参考答案(文本框里是正确答案 程序改错参考答案 文本框里是正确答案) 文本框里是正确答案
Dim Age As Integer, Tree As Integer Age = 17 Tree = 3 Do Age = Age + 1 Tree = Tree + Age - 14 Loop Until Tree >= 100 Print "到"; Age; "岁时种到 100 棵树"

Private Sub Command1_Click() Dim Age As Integer, Tree As Integer Age = 17 Do Age = Age + 1 Tree = Tree + Age - 14 Loop Until Tree = 100 Print "到"; Age; "岁时种到 100 棵树" End Sub

2、累乘(1×2×3×……×9×10=?) Private Sub Command1_Click() Dim S As Integer, A As Integer For A = 1 To 10 S = S *A Next S Print "S="; S End Sub Private Sub Command1_Click() Dim S As Integer, A As Integer S=1 For A = 1 To 10 S = S *A Next A Print "S="; S

3、求解一元二次方程的程序

Private Sub Command5_Click() Dim a, b, c, d As Integer Dim x1, x2 As Single a = InputBox("请输入二次项系数:", "输入") b = InputBox("请输入一次项系数:", "输入") c = InputBox("请输入常数项:", "输入") d=b^2-4ac If d >= 0 Then x1 = (-b + Sqr(d)) / 2 * a x2 = (-b - Sqr(d)) / 2 * a Print "X1="; x1, "X2="; x2 Else Print "此一元二次方程无解!" End Sub Dim a, b, c, d As Integer Dim x1, x2 As Single a = InputBox("请输入二次项系数:", "输入") b = InputBox("请输入一次项系数:", "输入") c = InputBox("请输入常数项:", "输入") d=b^2-4*a*c If d >= 0 Then x1 = (-b + Sqr(d)) / 2 * a x2 = (-b - Sqr(d)) / 2 * a Print "X1="; x1, "X2="; x2 Else Print "此一元二次方程无解!" End If

4、百钱买百鸡: “今有鸡翁一值钱五,鸡母一值钱三,鸡雏三值钱一,凡百钱买百鸡,问鸡翁、鸡母、鸡雏 各几何。。 ” For a = 0 To 20 Private Sub Command1_Click() For b = 0 To 33 Dim a As Integer, b As Integer, c As Integer For c = 0 To 99 Step 3 For a = 0 To 20 For b = 0 To 33 For c = 0 To 99 Step 3 If (a + b + c = 100) Or (5 * a + 3 * b + c / 3 = 100) Then Print a, b, c If (a + b + c = 100) And (5 * a + 3 * b + c / 3 = 100) Then Print a, b, c Next c Next b Next a

Next a Next b Next c End Sub

5、判断某年是否闰年 Private Sub Command1_Click() Dim N As Integer N = InputBox("输入年号:", "判断闰年", 2000) If N / 100 <> N \ 100 Then If N Mod 400 = 0 Then Print "不是闰年" Else Print "闰年" If N / 100 = N \ 100 Then Else If N Mod 4 = 0 Then Print "不是闰年" Else Print "闰年" End If End Sub If N Mod 400 = 0 Then Print "闰年" Else Print "不是闰年" Else If N Mod 4 = 0 Then Print "闰年" Else Print "不是闰年" End If Dim N As Integer N = InputBox("输入年号:", "判断闰年", 2000)


相关文档

高中信息技术学业水平考试 程序设计知识点汇总
高中信息技术学业水平考试 程序设计知识点汇总资料
高中信息技术学业水平考试程序设计知识点汇总要点
山东高中信息技术学业水平考试2018年6月算法与程序设计1-5套题(附答案及解析)
VB程序设计初步(高中信息技术课程)
高中信息技术学业水平考试专题复习 VB程序典型错误分析
高中信息技术学业水平考试算法与程序设计题、填空题、分析题小抄版含答案
省2018高中信息技术学业水平考试算法与程序设计模块测
云南省2018高中信息技术学业水平考试算法与程序设计模块测
电脑版