Learn Delphi 1(record and function)
program Project2;
{$APPTYPE CONSOLE}
uses SysUtils;
type weekname = record
chname:string;
enname:string;
end;
const
chnamearray: array[1..7]of string =('c1','c2','c3','c4','c5','c6','c7');
ennamearray: array[1..7]of string =('1e','e2','e3','e4','e5','e6','e7');
testarray: array[1..7] of weekname = (
(chname:'c1'; enname:'e1'),
(chname:'c2'; enname:'e2'),
(chname:'c3'; enname:'e3'),
(chname:'c4'; enname:'e4'),
(chname:'c5'; enname:'e5'),
(chname:'c6'; enname:'e6'),
(chname:'c7'; enname:'e7')
);
var
total:integer;
weeknum:integer;
wk: weekname;
function Factorial(num: integer) :integer ;
var temp:integer;
begin
if(num=0) or (num=1) then
temp:=1
else
temp:= Factorial(num-1) * num;
result := temp;
end;
function ShowWeek(n:integer):weekname;
begin
result := testarray[n+1];
end;
begin
total := Factorial(4) + Factorial(6) + Factorial(9);
writeln('4!+6!+9! :', total);
readln;
read(weeknum);
wk := testarray[weeknum+1];
writeln('ch name : ', wk.chname);
writeln('en name : ', wk.enname);
readln;
readln;
end.