⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pr06009.cpp

📁 c++编程宝典源码及Quincy99编译器 是《标准C++编程宝典》电子工业出版社的光盘
💻 CPP
字号:
////////////////////////////////////////
// File Name: pr06009.cpp
////////////////////////////////////////
#include <iostream>

// Function prototype.
int* GetDate(int wk, int dy);

////////////////////////////////////////
// The main() function.
////////////////////////////////////////
int main()
{
    int wk, dy;

    do
    {
        std::cout << "Enter week (1-5) day (1-7) ";
        std::cin >> wk >> dy;
    }
    while (wk < 1 || wk > 6 || dy < 1 || dy > 7);

    std::cout << *GetDate(wk, dy);

    return 0;
}

////////////////////////////////////////
// Get an address for the appropriate
// date array element.
////////////////////////////////////////
int* GetDate(int wk, int dy)
{
    static int calendar[5][7] =
    {
        {  1, 2, 3, 4, 5, 6, 7 },
        {  8, 9,10,11,12,13,14 },
        { 15,16,17,18,19,20,21 },
        { 22,23,24,25,26,27,28 },
        { 29,30,31,-1 }
    };

    // Return the address of the date.
    return &calendar[wk-1][dy-1];
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -