四道数学算法程序设计题1.对任意正整数n,设计一个程序框图求s=1+二分之一+三分之一+……n分之一的值,写出程序.2.
1个回答

我只写代码!

1、 Input n (读出n的值)

S = 0

For i = 1 To n

S = S + 1 / i(累加)

Next i

Print S

2、这个有点麻烦,寡人口笨舍翘,描述不来!

3、Input a

Input b

Print a * b / 2

4、假如这个实数是X

Input X

Print Abs(X) 求绝对值!

分少题多条件高!

有些人说这是英语,请用中文描述!

do loop,until,while ,for next,if end if,x=0,print这些英语.看不懂也没办法啊!

流程图就免了吧!

第一题while语句代码

Input n

S = 0

i = 1

While i < 10

i = i + 1

S = S + 1 / i

Wend

Print S

第二题:

Input x(1),x(2),x(3),……,x(10)

Min = x(1)

Max = x(1)

For i = 1 To 9

If Min > x(i + 1) Then

Min = x(i + 1)

End If

If Max < x(i + 1) Then

Max = x(i + 1)

End If

Next i