pr06030.cpp
来自「c++编程宝典源码及Quincy99编译器 是《标准C++编程宝典》电子工业出」· C++ 代码 · 共 58 行
CPP
58 行
////////////////////////////////////////
// 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 + =
减小字号Ctrl + -
显示快捷键?