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