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

更新时间:2023-04-15 11:41:01 阅读量: 实用文档 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

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

文件编码(GHTU-UITID-GGBKT-POIU-WUUI-8968)

信息技术(选修

☆ 输入2个数,实现2个数的互换:

Dim a as single,b as single,t as single a= b= t=a a=b b=t =a =b

☆ 输入一个两位整数,十位和个位数值互换后输出: Dim x as integer

Dim ge as integer, shi as integer x=

shi=x\10 ge=x mod 10 =ge*10+shi

☆ 输入秒数,输出时分秒: Dim a as integer

Dim h as integer, m as integer,s as integer a=

h=a\3600 ‘计算小时部分 m=(a-3600*h) \60 或 m=(a mod 3600) \60

‘计算分钟部分

s=a mod 60 ‘计算秒部分 =h & “小时” & m & “分” & m & “秒”

☆ 输入一个年份,判断是否是闰年(年份能

被400整除或者 年份能被4整除但不被100整除): Dim y as integer y=

If (y mod 4=0 and y mod 100<>0 ) or y mod 400=0 then =”是闰年” Else

=”非闰年” End if

☆求S=1+2+3+……+N

Dim N as integer , s as integer

N=

S=0 For i=1 To N

S=S+i Next i

Print “S=”;S

程序题汇总

☆求S=1+3+5+……+(2*N -1 ) Dim N as integer , s as integer N=

S=0 For i=1 To (2*N -1) step 2 S=S+i Next i

Print “S=”;S

☆ 求S=1-2+3-4……+N

Dim N as integer , s as integer N=

S=0 For i=1 To N

S=S+I *(-1)^ ( i+1 ) Next i

Print “S=”;S

☆ 求S=1+1/2+1/3+……+1/N

Dim N as integer , s as integer N=

S=0 For i=1 To N S=S+ 1/ i Next i

Print “S=”;S

☆ 求S=1/2+2/3+3/4……+N/(N+1)

Dim N as integer , s as integer N=

S=0 For i=1 To N S=S+ i/ (i+1) Next i

Print “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 single Dim q as single,s as single a=

b=

c=

q=(a+b+c)/2

if (a+b)>c and (b+c)>a and (a+c)>b then

s=sqr(q*(q-a)(q-b)(q-c))

= “三角形面积是” & s

else

= “不能构成三角形”

end if

☆统计100以内能被3整除的数的个数:Dim n as integer

n=0

For i=1 to 100

If i mod 3 = 0 then

n=n+1 ‘n当作计数器,符合条件就+1 end if

next i

print n

☆输入5个数,输出其中的最大值:

Dim max as single,x a single

Max=inputbox(“输入一个数”)

For i=1 to 4

x=inputbox(“输入一个数”)

If max

Max=x

End if

Next i

Print max

☆输入一个学生的成绩,判断其优(80以上),良(60-80),不及格:

Dim score as single

Score=

If score>=80 then

Print “优”

Else

if score<60 then

Print “不及格”

Else

Print “良”

End if

End if

☆求5*6*…*25的积

Dim I As Integer Dim S As long

S = 1

For I = 5 to 25 Step 1

S = S * I

Next I

Print "求5*6*…*25的积:"; S

☆求10

11

9

10

8

9

7

8

6

7

5

6

4

5

3

4

2

3

2+

+

+

+

+

+

+

+

+

的值。

Dim I As Integer

Dim S As Double

S = 0

For I = 1 To 10 Step 1

S = S + (I + 1) / I

Next I

Print "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 Integer

Dim b As Integer

a =

b =

If Abs(a - b) < 50 Then

= "小于" Else

= "大于或等于" end if

☆求

657687981091-

----

的值。

Dim I As Integer Dim S As single

S = 1

For I = 10 To 6 Step -1

S = S - (I - 1) / I

Next I

Print "1-9/10-8/9-7/8-6/7-5/6 ="; S

☆已知三角形一条边C 的长度为5,在Text1、Text2分别输入边长a 和b,判断三条边能否构成一个三角形,如果是,则在Text3文本框中输出"能",否则在Text3文本框中输出"不能"。

Dim a As Single

Dim b As Single

a =

b =

If a + b > 5 And a + 5 > b And b + 5 > a Then = "能" Else = "不能" End If

☆求

10191817161514131211+

++++++++

的值。

Dim i As Integer

Dim S As single

S =0

For i = 1 To 10 Step 1

S =S+1 / i Next I

Print "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 =

b =

If (a + b) Mod 3 = 0 Then

= "能"

Else

= "不能"

End If

☆求5+10+15+……50 的和

Dim S As integer

S =0

For i = 50 To 5 Step -5

S =S+i

Next I

=S

☆输入一个整数,判断它的奇偶性 Dim x As integer

X=

If x mod 2=0 Then

= "偶数"

Else

= "奇数"

End If ☆输入一个数,判断它其是否是整数。

(Fix(x)取整)

Dim x As single

X=

If fix(x)=x Then

= "整数"

Else

= "不是整数"

End If

☆输入两个正整数,求他们的公约数并输出Dim x As Integer, y As Integer

x =

y =

For i = 2 To x

If 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 =

y =

max = 0

For i = 2 To x

If x Mod i = 0 And y Mod i = 0 Then max = i

End If

Next i

Print max

☆求一元二次方程式ax2+bx+c=0的解,a、b、c从键盘输入。

本文来源:https://www.bwwdw.com/article/wizq.html

Top