当前位置:文档之家› 福建信息技术会考VB程序题汇总

福建信息技术会考VB程序题汇总

信息技术(选修)☆输入2个数,实现2个数的互换:Dim a as single,b as single,t as singlea=text1.textb=text2.textt=aa=bb=ttext3.text=atext4.text=b☆输入一个两位整数,十位和个位数值互换后输出:Dim x as integerDim ge as integer, shi as integerx=text1.textshi=x\10ge=x mod 10text2.text=ge*10+shi☆输入秒数,输出时分秒:Dim a as integerDim h as integer, m as integer,s as integera=text1.texth=a\3600 ‘计算小时部分m=(a-3600*h) \60 或m=(a mod 3600) \60‘计算分钟部分s=a mod 60 ‘计算秒部分text2.text=h & “小时” & m & “分” & m & “秒”☆输入一个年份,判断是否是闰年(年份能被400整除或者年份能被4整除但不被100整除):Dim y as integery=text1.textIf (y mod 4=0 and y mod 100<>0 ) or y mod 400=0 then Text2.text=”是闰年”ElseText2.text=”非闰年”End if☆求S=1+2+3+……+NDim N as integer , s as integerN=text1.textS=0For i=1 To NS=S+iNext iPrint “S=”;S 程序题汇总☆求S=1+3+5+……+(2*N -1 )Dim N as integer , s as integerN=text1.textS=0For i=1 To (2*N -1) step 2S=S+iNext iPrint “S=”;S☆求S=1-2+3-4……+NDim N as integer , s as integerN=text1.textS=0For i=1 To NS=S+I *(-1)^ ( i+1 )Next iPrint “S=”;S☆求S=1+1/2+1/3+……+1/NDim N as integer , s as integerN=text1.textS=0For i=1 To NS=S+ 1/ iNext iPrint “S=”;S☆求S=1/2+2/3+3/4……+N/(N+1)Dim N as integer , s as integerN=text1.textS=0For i=1 To NS=S+ i/ (i+1)Next iPrint “S=”;S☆输入三角形三边,判断能否构成三角形,如可以则输出面积,否则输出“不能构成三角形“,设三边是a,b,c,q=(a+b+c)/2,则面积s=sqr(q*(q-a)(q-b)(q-c)):Dim a as single, b as single, c as singleDim q as single,s as singlea=text1.textb=text2.textc=text3.textq=(a+b+c)/2if (a+b)>c and (b+c)>a and (a+c)>b thens=sqr(q*(q-a)(q-b)(q-c))text4.text = “三角形面积是” & selsetext4.text = “不能构成三角形”end if1☆统计100以内能被3整除的数的个数:Dim n as integern=0For i=1 to 100If i mod 3 = 0 thenn=n+1 ‘n当作计数器,符合条件就+1end ifnext iprint n☆输入5个数,输出其中的最大值:Dim max as single,x a singleMax=inputbox(“输入一个数”)For i=1 to 4x=inputbox(“输入一个数”)If max<x thenMax=xEnd ifNext iPrint max☆输入一个学生的成绩,判断其优(80以上),良(60-80),不及格:Dim score as singleScore=Text1.textIf score>=80 thenPrint “优”Elseif score<60 thenPrint “不及格”ElsePrint “良”End ifEnd if☆求5*6*…*25的积Dim I As IntegerDim S As longS = 1For I = 5 to 25 Step 1S = S * INext IPrint "求5*6*…*25的积:"; S☆求1011910897867564534232+++++++++的值。

Dim I As IntegerDim S As DoubleS = 0For I = 1 To 10 Step 1S = S + (I + 1) / INext IPrint "2+3/2+4/3+5/4+6/5+…+11/10 ="; S☆在Text1输入整数a、Text2输入整数b,判断a和b的差是否比50小,若比50小,则在Text3文本框中输出"小于",否则在Text3文本框中输出:"大于或等于"。

Dim a As IntegerDim b As Integera = Text1.Textb = Text1.TextIf Abs(a - b) < 50 ThenText3.Text = "小于"ElseText3.Text = "大于或等于"end if☆求657687981091-----的值。

Dim I As IntegerDim S As singleS = 1For I = 10 To 6 Step -1S = S - (I - 1) / INext IPrint "1-9/10-8/9-7/8-6/7-5/6 ="; S☆已知三角形一条边C的长度为5,在Text1、Text2分别输入边长a和b,判断三条边能否构成一个三角形,如果是,则在Text3文本框中输出"能",否则在Text3文本框中输出"不能"。

Dim a As SingleDim b As Singlea = Text1.Textb = Text2.TextIf a + b > 5 And a + 5 > b And b + 5 > a ThenText3.Text = "能"ElseText3.Text = "不能"End If23☆求10191817161514131211+++++++++的值。

Dim i As IntegerDim S As single S =0For i = 1 To 10 Step 1 S =S+1 / i Next IPrint "1+1/2+1/3+1/4+1/5+…+1/10="; S☆在Text1输入整数a 、Text2输入整数b ,判断a 和b 的和能否被3整除,若能,则在Text3文本框中输出"能",否则在Text3文本框中输出:"不能"Dim a As integer Dim b As integer a = Text1.Text b = Text2.TextIf (a + b) Mod 3 = 0 Then Text3.Text = "能" ElseText3.Text = "不能" End If☆ 求5+10+15+……50 的和Dim S As integer S =0For i = 50 To 5 Step -5 S =S+i Next IText3.text=S☆ 输入一个整数,判断它的奇偶性 Dim x As integer X=text1.textIf x mod 2=0 ThenText3.Text = "偶数" ElseText3.Text = "奇数" End If☆ 输入一个数,判断它其是否是整数。

(Fix(x)取整) Dim x As single X=text1.text If fix(x)=x ThenText3.Text = "整数" ElseText3.Text = "不是整数" End If☆输入两个正整数,求他们的公约数并输出 Dim x As Integer, y As Integer x = Text1.Text y = Text2.Text For i = 2 To xIf x Mod i = 0 And y Mod i = 0 Then Print i End If Next i☆输入两个正整数,求他们的最大公约数并输出 Dim x As Integer, y As Integer, max As Integer x = Text1.Text y = Text2.Text max = 0For i = 2 To xIf x Mod i = 0 And y Mod i = 0 Then max = i End If Next i Print max☆求一元二次方程式ax 2+bx+c=0的解,a 、b 、c 从键盘输入。

相关主题