我想寫一個輸出日曆的程序。用戶必須輸入月份開始的那一天(星期一-0,星期二-1等)以及月中有多少天。根據月份開始的哪一天,日曆日期將在該特定日期之下開始。我遇到的問題是,我不確定如何讓日曆在特定的一天開始,而且我不確定如何在7天后將日期更改爲新的行。任何幫助,將不勝感激。到目前爲止,我們還沒有學到很多,所以我只允許使用基礎知識,沒有功能或類似的東西。C + +日曆問題
這是我到目前爲止。我可能會遠離。
#include <iostream>
#include <iomanip>
#include <conio.h>
using namespace std;
int main()
{
int monthStartDay, daysInMonth;
cout << "Enter the first day of the month: ";
cin >> monthStartDay;
cout << "Enter how many days are in the month: ";
cin >> daysInMonth;
cout<<"\nSun Mon Tue Wed Thu Fri Sat";
cout<<"\n\n"<<setw(2);
for (int x=1; x <= daysInMonth; x++){
cout << x << setw(6);
for (int i=1; i == 6; i++) {
cout << "\n";
}
}
return 0;
}
我有一個在相關職位上的答案 http://stackoverflow.com/questions/37582163/c-calendar-loop-design/37582461#37582461 – winux