主题:[讨论]大家讨论一下这个程序效率
Program Example;
{ This program is about work out the day number which is the next one that
people type it
By : Zuo XingDong
Time: 2007.2.3
}
Type
Days = (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday);
Var
Today, Tomorrow: Days;
n: Integer;
Begin
Write('n(0,1,2,3,4,5,6)='); ReadLn(n);
Case n Of
0: Today := Sunday;
1: Today := Monday;
2: Today := Tuesday;
3: Today := Wednesday;
4: Today := Thursday;
5: Today := Friday;
6: Today := Saturday;
End;
If Today = Saturday Then Tomorrow := Sunday Else Tomorrow := Succ(Today);
Write('Tomorrow is ');
Case Tomorrow Of
Sunday: WriteLn('Sunday');
Monday: WriteLn('Monday');
Tuesday: WriteLn('Tuesday');
Wednesday: WriteLn('Wednesday');
Thursday: WriteLn('Thursday');
Friday: WriteLn('Friday');
Saturday: WriteLn('Saturday');
End;
ReadLn;
End.
-----------------------------------------------------------------------
这个程序执行效率如何阿?有没有更简便的方法呢?谢谢大家
{ This program is about work out the day number which is the next one that
people type it
By : Zuo XingDong
Time: 2007.2.3
}
Type
Days = (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday);
Var
Today, Tomorrow: Days;
n: Integer;
Begin
Write('n(0,1,2,3,4,5,6)='); ReadLn(n);
Case n Of
0: Today := Sunday;
1: Today := Monday;
2: Today := Tuesday;
3: Today := Wednesday;
4: Today := Thursday;
5: Today := Friday;
6: Today := Saturday;
End;
If Today = Saturday Then Tomorrow := Sunday Else Tomorrow := Succ(Today);
Write('Tomorrow is ');
Case Tomorrow Of
Sunday: WriteLn('Sunday');
Monday: WriteLn('Monday');
Tuesday: WriteLn('Tuesday');
Wednesday: WriteLn('Wednesday');
Thursday: WriteLn('Thursday');
Friday: WriteLn('Friday');
Saturday: WriteLn('Saturday');
End;
ReadLn;
End.
-----------------------------------------------------------------------
这个程序执行效率如何阿?有没有更简便的方法呢?谢谢大家