Write a program to print a set of either odd or even numbers according to the user’s will.
Example1:Enter the target: 10
Even/Odd? Even
The even numbers are 2 4 6 8 10
Example2:Enter the target: 10
Even/Odd? Odd
The odd numbers are 1 3 5 7 9
如果要咁,要點做吖???
以下係我自己做,但係錯左...:
program ex4;
var
i,num:integer;
a:string;
begin
write('Enter the target: ');
readln(num);
write('Even/Odd: ');
readln(a);
if a = 'Odd' then
write('The odd numbers are: ') ;
for i := 1 to num do
begin
write(i,' ');
i := i + 1;
end;
readln();
if a = 'Even' then
write('The even numbers are: ');
for i := i + 2 to num do
begin
write(i,' ');
i := i + 1;
end;
readln();
end.
希望有人解答到...吾該:D