文档介绍:基本算法语句****题课
温故知新
基本算法语句有四种:
1、赋值语句用符号“”表示,
2、输入语句用“Read a , b”表示输入的数据依次送给a , b
用输出语句“ Print x”表示输出运算结果
3、条件语句,其一般形式是:
If A then B
Else C
End if
4、循环语句
(1)“For”语句(循环次数已定时).
一般形式为:
For I from“初值”to“终值”step“步长”…End for
(2)“While”语句(循环次数不定时).
一般形式为
While A
…
End while
应用
1、任给三个变量a,b,c赋值,求下列各式的值:
(1)a+b+c; (2)b2-4ac.
解:(1)Read a,b,c
y←a+b+c
Print y
(2)Read a,b,c
y←b2-4ac
Print y
2、试写出解决求函数y=
的函数值这一问题的伪代码。
Read x
If X<2 then
y=x2-1
Else
y=-x2+1
End if
Print y
3、计算300(1+)10.
解:s←300
c←1+
I←1
For I from 1 to 10 step 1
s←s×c
End for
Print s
解:s←300
c←1+
I←1
For I from 1 to 10
s←s×c
End for
Print s
4、设计一个算法,求平方后所有小于10000的正整数。
解:I←1
s←I2
While s<10000
Print I
I←I+1
End while
解:伪代码如右:
5、用循环语句描述求
的算法.
S←1
I←2
a←1
While I≤100
a←a×(-1)
S←S+
End while
Print S
练****br/>. 8,10题
《高中数学3课课练单元测试》~27 6到10题