C++ 日历,在我看到输出之前关闭

标签 c++ calendar

所以基本上我创建了这个日历,当它输出时你可以简单地看到它是正确的但它只是关闭,有人可以帮我让它保持打开状态以显示输出吗? 我知道我应该知道这是什么,但这花了我很长时间,而且我的想法不在正确的地方。谢谢


#include "stdafx.h"
#include <conio.h>
#include <iostream>
#include <iomanip>
#include "float.h"
#include <stack>

using namespace std;

using std::stack;

int calendar[6][7];
void cal(int y, int z) // y is number of days and z is the number corresponding 
{                              // to the first day
    int n = 1;
    for (int j = z - 1; j<7; j++)
    {
        calendar[0][j] = n;
        n++;
    }
    for (int i = 1; i<6 && n <= y; i++)
    {
        for (int k = 0; k<7 && n <= y; k++)
        {
            calendar[i][k] = n;
            n++;
        }
    }
}
int main()
{
    int d;
    int day;
    cout << "Enter number of days : ";
    cin >> d;
    cout << "Enter first day of the month(1 for monday 7 for sunday..) : ";
    cin >> day; cout << "\n";
    cal(d, day);
    cout << "M       T       W       T       F       S       S" << endl;
    cout << "\n";
    for (int i = 0; i<6; i++)
    {
        for (int j = 0; j<7; j++)
        {
            cout << calendar[i][j] << "\t";
        }
        cout << "" << endl; 
    }
}

最佳答案

使用 std::cin.get() 保持窗口打开。

关于C++ 日历,在我看到输出之前关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19884296/

相关文章:

c++ - 传递给模板函数的可变参数模板

c++ - 在 C++ 中使用指向 char 数组的指针

java:如何模拟 Calendar.getInstance()?

Excel 创建 Outlook 日历事件

java - 如何获取某个月份的所有日期

c++ - 检查返回值是整数还是字符

c++ - 如何避免第三方库(无源代码)从物理内存分配内存?

c++ - 主线程无法从工作线程获取信号

java - 仅打印工作日

Java - Calendar.getTime 不检索使用 Calendar.setTime 设置的日期