Files
some-cpp-files/Practical-Teaching/OPP-in-C++/1/2.cpp
T
2024-03-17 22:30:49 +08:00

26 lines
498 B
C++

// day(0~6)代表每月第一天起始位置,stop代表每月天数,每天之间空两个空格。输入不同的day和stop,输出每月日历的样子。
#include <bits/stdc++.h>
using namespace std;
int main() {
int day, stop;
cin >> day >> stop;
cout << " Sun Mon Tue Wed Thu Fri Sat" << endl;
int t = day;
while (t--) {
cout << " ";
}
for (int i = 1; i <= stop; i++) {
cout << setw(5) << i;
if ((i + day) % 7 == 0) {
cout << endl;
}
}
return 0;
}