2012年2月20日 星期一

Exercise #1


Exercise #1

Use the Date struct, the MonthName array, the function prototypes, the main() and the output below to complete the following program. Make sure that you use C++ ANSI standard header files. Try to match the output exactly. Turn in your entire program and the output.

struct Date
{
    unsigned short month;
    unsigned short day;
    unsigned short year;
};

const char* MonthName[12] = {"January","February","March","April","May",
"June","July","August","September","October","November","December"};

void InputDate(Date*);
void Print1(Date);
void Print2(Date);
void Print3(Date);

int main()
{
    Date FirstDay, FinalDay, HoliDay;
    InputDate(&FirstDay);
    InputDate(&FinalDay);
    InputDate(&HoliDay);
    Print1(FirstDay);
    Print2(FirstDay);
    Print3(FirstDay);
    Print1(FinalDay);
    Print2(FinalDay);
    Print3(FinalDay);
    Print1(HoliDay);
    Print2(HoliDay);
    Print3(HoliDay);
    return 0;
}

******  Program Output  ******

Enter month day year (separated by spaces) => 1 13 2005
Enter month day year (separated by spaces) => 1 1 2005
Enter month day year (separated by spaces) => 12 14 2005
01/13/05
January 13, 2005
13JAN05
01/01/05
January 1, 2005
01JAN05
12/14/05
December 14, 2005
14DEC05

沒有留言:

張貼留言