编写一个程序,提示用户输入一个年份以及这一年中第一天是星期几,
然后,输出每个月的第一天是星期几。
#include <iostream>
using namespace std;
int main()
{
cout << "Enter a year: ";
int year;
cin >> year;
cout << "Enter the first day of the year: ";
int firstDay;
cin >> firstDay;
int numberOfDaysInMonth = 0;
// Display calendar for each month
for (int month = 1; month <= 12; month++)
{
// Display Calendar title
switch (month)
{
case 1:
cout << "January 1, " << year << " is ";
numberOfDaysInMonth = 31;
break;
case 2:
&nbs

该C++程序要求用户输入一年的年份和该年的第一天是星期几,然后逐月显示这一年内每个月的第一天是星期几。程序通过计算每个月份的天数和星期的循环,实现了这一功能。
最低0.47元/天 解锁文章
826

被折叠的 条评论
为什么被折叠?



