Listing: 1 MODULE prog4; 2 (* This program displays the permutations of a string 3 in alphabetic order *) 4 IMPORT IO,Str; 5 6 TYPE StringType = ARRAY [0..9] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 7 8 PROCEDURE NextPerm(n:CARDINAL; 9 VAR s:StringType; 10 VAR wrap:BOOLEAN); 11 (* This procedure updates s to the next permutation of the 12 first n characters of s. The sequence of permutations 13 generated by successive calls is in 'dictionary' order. 14 If s is the last string in the sequence, the first is 15 returned. The boolean result wrap is used to indicate 16 this event *) 17 VAR 18 i:CARDINAL; (* s[i-1] is the most significant char changed *) 19 j:CARDINAL; (* s[j] is the char to be swapped with s[i-1] *) 20 tmp:CHAR; 21 22 BEGIN 23 IF n = 0 THEN 24 wrap := TRUE; 25 RETURN; 26 END; 27 i := n - 1; 28 LOOP 29 IF i = 0 THEN 30 wrap := TRUE; 31 EXIT; 32 END; 33 IF s[i-1] < s[i] THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 34 j := n - 1; 35 WHILE s[j] <= s[i-1] DO ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 36 j := j - 1; 37 END; 38 tmp := s[j]; s[j] := s[i-1]; s[i-1] := tmp; (* swap *) ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 39 wrap := FALSE; 40 EXIT; 41 END; 42 i := i - 1; 43 END; 44 (* s[i]..s[n-1] are in reverse order, reversing them 45 yields the minimum permutation we require *) 46 j := n - 1; 47 WHILE i < j DO 48 tmp := s[j]; s[j] := s[i]; s[i] := tmp; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 49 i := i + 1; 50 j := j - 1; 51 END; 52 END NextPerm; ***** ^ not supported yet 53 54 VAR InputString:StringType; ***** ^ not supported yet 55 wrap:BOOLEAN; 56 online:CARDINAL; (* number of strings in output line *) 57 len:CARDINAL; 58 BEGIN 59 IO.WrStr('Enter string : '); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 60 IO.RdStr(InputString); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 61 62 len := Str.Length(InputString); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 63 REPEAT 64 NextPerm(len,InputString,wrap); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 65 UNTIL wrap; 66 67 online := 0; 68 REPEAT 69 IO.WrStr(InputString); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 70 IO.WrStr(' '); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 71 online := online + 1; 72 IF online = 6 THEN 73 IO.WrLn; ***** ^ not supported yet ***** ^ not supported yet 74 online := 0; 75 END; 76 NextPerm(len,InputString,wrap); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 77 UNTIL wrap; 78 END prog4. 79 51 errors