📄 pr06030.cpp
字号:
////////////////////////////////////////
// File Name: pr06030.cpp
////////////////////////////////////////
#include <iostream>
// Date structure.
struct Date
{
int month, day, year;
};
// Function prototypes.
void display(const Date&, const char*);
void swapper(Date&, Date&);
////////////////////////////////////////
// The main() function.
////////////////////////////////////////
int main()
{
// define two dates.
static Date now = {2,23,90};
static Date then = {9,10,60};
// Display the dates.
display(now, "Now: ");
display(then, "Then: ");
// Swap the dates and redisplay them.
swapper(now, then);
display(now, "Now: ");
display(then, "Then: ");
return 0;
}
////////////////////////////////////////
// Swap the caller's dates.
////////////////////////////////////////
void swapper(Date& dt1, Date& dt2)
{
Date save;
save = dt1;
dt1 = dt2;
dt2 = save;
}
////////////////////////////////////////
// Display a Date object.
////////////////////////////////////////
void display(const Date& dt, const char* ttl)
{
std::cout << ttl;
std::cout << dt.month << '/'
<< dt.day << '/'
<< dt.year << std::endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -