Else ,
End
If then 1
End
, 1, 2, 3 ;
1, 2, Ж Scilab.
. , .
.
1
- (0 1).
- , , then, if .
- , , else, if .
- (0 1).
- , , then, if .
- , if .
.
== | x==y | |
~= | x~=y | |
< | x<y | |
> | x>y | |
<= | x<=y | |
>= | x>=y | |
& | x&y | |
| | x|y | |
~ | ~x |
, : a > b c <= 5.8. , :
a>b | b<0
(a > 0) & (b>0)
, if " " " "
b^2 - 4*a*c.
if b^2 - 4*a*c < 0 then disp(" ") else disp(" ")end, . , .
Scilab :
- for;
- while.
, , , . :
- ;
- .
for , .
|
|
for
for x= xn: dx: xk
,
End
:
x ,
xn ,
dx ,
xk ,
.
:
- xn<=xk;
- , , ;
- , x=xn;
- ;
- , x< = xk dx .
:
|xk xn|/dx +1.
for:
for k=1: 5 disp(k) end |
while , .
:
While ,
,
End
,
.
:
- ;
- , , ;
- , .
while , .
while .
2 12.
k=2;
while k<=20
Disp(k)
k=k+2;
End
1.
. y(x). . y(x) x.
.
1. input.
2. , x > 20, , y=sqrt(x).
3. if, , , . 2 elseif .
4. if, else, . if end.
5. .
x= input (" =")if x>20 then y=sqrt(x), elseif (x>=1) & (x<=20) then y=x else y=4*x^2 enddisp('y=')disp(y) | =25 y= 5. =15 y= 15. =-3 y= 36. |
2.7.
2.7.
1. | 2. | ||
3. | 4. | ||
5. | 6. | ||
7. | 8. | ||
9. | 10. | ||
11. | 12. | ||
13. | 14. | ||
15. | 16. |
2.
|
|
. N. . ( ).
. |
.
1. X . , . .
2. P, 1.
3. , , , , 2, 4, 6 .., i. 2, .. .
4. , ( i) . 10 , : while i<=10.
5. if, , , .. . , . if end.
6. 2 (i=i+2) end.
7. .
X=[-2 -3 -6 5 2 -4 8 9 -10 -7]P=1; i=2while i<=10 if X(i)<0 then P=P*X(i) end i=i+2enddisp(X); disp(P) | - 2. - 3. - 6. 5. 2. - 4. 8. 9. - 10. - 7. - 84. |
2.8.
2.8.
1. | , [ 3,15,4] |
2. | |
3. | , |
4. | , 7 |
5. | |
6. | , 5 |
7. | , |
8. | , |
9. | , [ 2,58,4] |
10. | , |
11. | |
12. | , 12 |
13. | , 4 |
14. | |
15. |