Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h> // Ver: 01
- enum Day {Monday = 1, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday};
- Day yesterday,
- today,
- tomorrow;
- //////////////////////////////////////////////////////
- int main() //
- {
- today = Tuesday;
- printf("yesterday = %d\n", yesterday);
- printf("today = %d\n", today );
- printf("tomorrow = %d\n", tomorrow );
- }
- /*
- #include <stdio.h> // Ver: 02
- enum Day {Monday = 1, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday};
- Day yesterday,
- today,
- tomorrow;
- void Change_today(Day);
- void Show_the_day( );
- //////////////////////////////////////////////////////
- int main() //
- {
- today = Tuesday;
- Show_the_day();
- Change_today(Sunday);
- Show_the_day();
- }
- //////////////////////////////////////////////////////
- void Change_today(Day d) //
- {
- yesterday = static_cast<Day>(d - 1);
- today = d;
- tomorrow = (Day)(d + 1);
- if(d == Sunday) tomorrow = Monday;
- if(d == Monday) yesterday = Sunday;
- }
- //////////////////////////////////////////////////////
- void Show_the_day() //
- {
- printf("yesterday = %d\n", yesterday);
- printf("today = %d\n", today );
- printf("tomorrow = %d\n", tomorrow );
- printf(" - - - - - - - - - - - - \n");
- }
- */
- /*
- #include <stdio.h> // Ver: 03
- enum Day {Monday = 1, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday};
- Day yesterday,
- today,
- tomorrow;
- void Change_today(Day);
- void Show_the_day( );
- //////////////////////////////////////////////////////
- int main() //
- {
- today = Tuesday;
- Show_the_day();
- Change_today(Sunday);
- Show_the_day();
- }
- //////////////////////////////////////////////////////
- void Change_today(Day d) //
- {
- yesterday = static_cast<Day>(d - 1);
- today = d;
- tomorrow = (Day)(d + 1);
- if(d == Sunday) tomorrow = Monday;
- if(d == Monday) yesterday = Sunday;
- }
- //////////////////////////////////////////////////////
- void Show_the_day() //
- {
- char szDays[8][11] = { "void",
- "Monday",
- "Tuesday",
- "Wednesday",
- "Thursday",
- "Friday",
- "Saturday",
- "Sunday"};
- printf("yesterday = %9s\n", szDays[yesterday]);
- printf("today = %9s\n", szDays[today ]);
- printf("tomorrow = %9s\n", szDays[tomorrow ]);
- printf(" - - - - - - - - - - - - \n");
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement