| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- Listing:
- 1 MODULE prog5;
- 2 (* this program lists the 9-digit numbers, containing every
- 3 digit from 1 to 9 which are a product of three 3-digit
- 4 numbers, which also contain every digit from 1 to 9 *)
- 5 IMPORT IO;
- 6 FROM perms IMPORT NextPerm;
- 7
- 8 PROCEDURE check(n:LONGCARD):BOOLEAN;
- ***** ^ undeclared identifier
- 9 (* Checks if the digits of n are a permutation of 1..9 *)
- 10 VAR i:[1..9];
- 11 digit:[0..9];
- 12 seen:ARRAY [0..9] OF BOOLEAN;
- ***** ^ not supported yet
- ***** ^ not supported yet
- 13 BEGIN
- 14 seen[0] := TRUE;
- ***** ^ not supported yet
- ***** ^ not supported yet
- 15 FOR i := 1 TO 9 DO
- 16 seen[i] := FALSE;
- ***** ^ not supported yet
- ***** ^ not supported yet
- 17 END;
- 18 FOR i := 1 TO 9 DO
- 19 digit := CARDINAL(n MOD 10); (* n MOD 10 is the remainder
- ***** ^ not supported yet
- ***** ^ not supported yet
- 20 when n is divided by 10 *)
- 21 IF seen[ digit ] THEN
- ***** ^ not supported yet
- ***** ^ not supported yet
- 22 RETURN FALSE;
- 23 ELSE
- 24 seen[ digit ] := TRUE;
- ***** ^ not supported yet
- ***** ^ not supported yet
- 25 END;
- 26 n := n DIV 10; (* DIV means whole number division *)
- ***** ^ not supported yet
- ***** ^ not supported yet
- 27 END;
- 28 RETURN TRUE;
- 29 END check;
- ***** ^ not supported yet
- 30
- 31 VAR d:ARRAY[0..8] OF SHORTCARD;
- ***** ^ not supported yet
- ***** ^ not supported yet
- 32 a,b,c:CARDINAL;
- 33 n:LONGCARD;
- ***** ^ undeclared identifier
- 34 i:CARDINAL;
- 35 wrap:BOOLEAN;
- 36 BEGIN
- 37 FOR i := 0 TO 8 DO
- 38 d[i] := SHORTCARD(i) + 1;
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 39 END;
- 40
- 41 REPEAT
- 42 a := CARDINAL(d[0])*100 + CARDINAL( d[1]*10 + d[2] );
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 43 b := CARDINAL(d[3])*100 + CARDINAL( d[4]*10 + d[5] );
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 44 c := CARDINAL(d[6])*100 + CARDINAL( d[7]*10 + d[8] );
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 45 n := LONGCARD(a) * LONGCARD(b) * LONGCARD(c);
- ***** ^ not supported yet
- ***** ^ undeclared identifier
- ***** ^ not supported yet
- ***** ^ undeclared identifier
- ***** ^ not supported yet
- ***** ^ undeclared identifier
- ***** ^ not supported yet
- 46
- 47 IF check(n) THEN
- ***** ^ not supported yet
- ***** ^ not supported yet
- 48 IO.WrStr('A solution is ');
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 49 IO.WrCard(a, 1);
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 50 IO.WrStr(' x ');
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 51 IO.WrCard(b, 1);
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 52 IO.WrStr(' x ');
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 53 IO.WrCard(c, 1);
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 54 IO.WrStr(' = ');
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 55 IO.WrLngCard(n, 1);
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 56 IO.WrLn;
- ***** ^ not supported yet
- ***** ^ not supported yet
- 57 END;
- 58 NextPerm(9,d,wrap);
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 59 UNTIL wrap;
- 60 END prog5.
- 61
- 79 errors
|