-
Notifications
You must be signed in to change notification settings - Fork 0
/
example6.st
128 lines (110 loc) · 1.95 KB
/
example6.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
{%
% Example of nested IF, nested FOR loops, nested LOOP loops
%}
% global variables
var a :int := 6
var b := 4
var c :int
var i :int
var j :int
var k :int
const n := 5
c := a - b -1
if a>b then
put "a is greater than b\n"
if (b>c) then
put "b is greater than c\n"
else
put "b is not greater than c\n"
end if
else
put "a is not greater than b\n"
if (a>c) then
put "a is greater than c\n"
else
put "a is not greater than c\n"
end if
end if
if a>b then
put "a is greater than b\n"
if (b>c) then
put "b is greater than c\n"
if a>c then
put "a is greater than c\n"
else
put "a is not greater than c\n"
end if
else
put "b is not greater than c\n"
end if
else
put "a is not greater than b\n"
if (a>c) then
put "a is greater than c\n"
if c>b then
put "c is greater than b\n"
else
put "c is not greater than b\n"
end if
else
put "a is not greater than c\n"
end if
end if
skip
if (a > b and b > c) then
put ("a is greater than b and b is greater than c.\n")
if (a mod 2 = 0) then
put ("a is an even number.\n")
if (b mod 2 = 0) then
put ("b is also an even number.\n")
if (c mod 2 = 0) then
put ("c is also an even number.\n")
else
put ("c is not an even number.\n")
end if
else
put ("b is not an even number.\n")
end if
else
put ("a is not an even number.\n")
end if
else
put ("The condition a > b && b > c is not satisfied.\n")
end if
skip
for decreasing i : n..1
put i
skip
for j : 1..n
put ">"
put j
skip
for k : 1..n
put ">>"
put k
end for
skip
end for
skip
skip
end for
skip
i:= 1
loop
exit when i > n
var j := 1
loop
exit when j > i
var k := 1
loop
exit when k > j
put k
put " "
k := k + 1
end loop
j := j + 1
skip
end loop
i := i + 1
skip
end loop