function occ (nums : array 1 .. * of int, num : int) : int var count := 0 for i : 1 .. upper (nums) if nums (i) = num then count += 1 end if end for result count end occ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function median (nums : array 1 .. * of int) : int result nums (upper (nums) div 2) end median var n : array 1 .. 10 of int := init (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) put median (n) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function highest (nums : array 1 .. * of int) : int var g : int := 0 for i : 1 .. upper (nums) if nums (i) > g then g := nums (i) end if end for result g end highest var num : array 1 .. 10 of int put highest(num) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% proc topHalf (nums : array 1 .. * of real) var total : real := 0 var mean : real := 0 for i : 1 .. upper (nums) total := total + nums (i) end for mean := total / upper (nums) for i : 1 .. upper (nums) if nums (i) > mean then put nums (i) end if end for end topHalf var nums : array 1 .. 10 of real topHalf (nums) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% View.Set ("graphics") proc fillGrid var x : array 1 .. 20 of int var y : array 1 .. 20 of int var col : int for i : 1 .. upper (x) randint (x (i), 1, maxx - 30) randint (y (i), 1, maxy - 30) randint (col, 1, 25) drawfillbox (x (i), y (i), x (i) + 30, y (i) + 30, col) delay (100) end for for i : 1 .. upper (x) drawfillbox (x (i), y (i), x (i) + 30, y (i) + 30, white) delay (100) end for end fillGrid fillGrid %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% View.Set ("graphics:max,max") var x : array 1 .. 7 of int := init (0, 0, 0, 0, 0, 0, 0) var y : array 1 .. 7 of int := init (0, 0, 0, 0, 0, 0, 0) var mx, my, mb : int var clickCount : int := 0 proc up loop mousewhere (mx, my, mb) exit when mb = 0 end loop end up loop mousewhere (mx, my, mb) loop mousewhere (mx, my, mb) if mb = 1 and clickCount = 0 then drawfilloval (mx, my, 5, 5, blue) clickCount += 1 up exit elsif mb = 1 and clickCount >= 4 then drawfilloval (mx, my, 5, 5, blue) drawline (mx, my, x (1), y (1), red) drawfilloval (x (5), y (5), 10, 10, white) drawline (x (4), y (4), x (3), y (3), white) up exit elsif mb = 1 and clickCount >= 1 then drawfilloval (mx, my, 5, 5, blue) drawline (mx, my, x (1), y (1), red) clickCount += 1 up exit end if end loop x (1) := mx y (1) := my for decreasing i : 4 .. 2 x (i) := x (i - 1) y (i) := y (i - 1) end for end loop