Last change
on this file since f9ad69d was
7568e5c,
checked in by JiadaL <j82liang@…>, 3 months ago
|
Minor update on the thesis (add auto initialization and update future work
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Line | |
---|
1 | program test(Output); |
---|
2 | const Three = 2 + 1; NULL = NIL; PI = 3.14159; Plus = '+'; Fred = 'Fred'; |
---|
3 | type Week = ( Mon, Tue, Wed, Thu, Fri, Sat, Sun ); |
---|
4 | Weekday = Mon..Fri; |
---|
5 | Weekend = Sat..Sun; |
---|
6 | type Count = ( Zero, One, Two, Ten = 10, Eleven=10 ); |
---|
7 | type RR = ( A, B, C ); |
---|
8 | |
---|
9 | var day : Week; |
---|
10 | wday : Weekday; |
---|
11 | wend : Weekend; |
---|
12 | lunch : array[Week] of Integer; |
---|
13 | cnt : Count; |
---|
14 | // procedure P1(v:Week); |
---|
15 | // begin |
---|
16 | // Writeln('Week'); |
---|
17 | // end; |
---|
18 | procedure P1(v:Weekday); |
---|
19 | begin |
---|
20 | Writeln('Weekday'); |
---|
21 | end; |
---|
22 | procedure P1(v:RR); |
---|
23 | begin |
---|
24 | Writeln('RR'); |
---|
25 | end; |
---|
26 | begin |
---|
27 | day := Sat; |
---|
28 | wday := day; // invalid but allowed |
---|
29 | wend := day; // valid |
---|
30 | day := Mon; |
---|
31 | wday := day; // valid |
---|
32 | wend := day; // invalid but allowed |
---|
33 | day := wday; // valid |
---|
34 | day := wend; // valid |
---|
35 | if day = wday then |
---|
36 | Writeln( day ); |
---|
37 | if day <= Fri then |
---|
38 | Writeln( 'weekday'); |
---|
39 | case day of |
---|
40 | Mon..Fri : |
---|
41 | Writeln( 'weekday'); |
---|
42 | Sat..Sun : |
---|
43 | Writeln( 'weekend') |
---|
44 | end; |
---|
45 | day := Mon; |
---|
46 | while day <= Sat do begin |
---|
47 | Write( day, ' ' ); |
---|
48 | day := succ( day ); |
---|
49 | end; |
---|
50 | Writeln(); |
---|
51 | for day := Mon to Sat do begin |
---|
52 | Write( day, ' ' ); |
---|
53 | end; |
---|
54 | Writeln(); |
---|
55 | for day := Mon to Sat do |
---|
56 | lunch[day] := ord(day) * 10; |
---|
57 | for day := Mon to Sun do |
---|
58 | Write( lunch[day], ' ' ); |
---|
59 | Writeln(); |
---|
60 | for cnt := Zero to Eleven do begin |
---|
61 | Write( ord( cnt ), ' ' ); |
---|
62 | end; |
---|
63 | day := Tue; |
---|
64 | P1( day ); |
---|
65 | Writeln(); |
---|
66 | |
---|
67 | case (day) of |
---|
68 | Mon: writeln('Excellent!' ); |
---|
69 | Tue: writeln('Well done' ); |
---|
70 | end; |
---|
71 | end. |
---|
72 | |
---|
73 | { Local Variables: } |
---|
74 | { tab-width: 4 } |
---|
75 | { pascal-indent-level: 4 } |
---|
76 | { compile-command: "fpc test.pas" } |
---|
77 | { End: } |
---|
Note: See
TracBrowser
for help on using the repository browser.