1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#include <iostream> #include <iomanip> using namespace std; int main() { int month, first, total, newline = 6; cout << "輸入月份:"; cin >> month; cout << "輸入" << month << "月1日是星期幾:"; cin >> first; cout << "輸入" << month << "月總天數:"; cin >> total; cout << setw(10) << "2018年" << month << "月" << endl; cout << setw(3) << "日" << setw(3) << "一" << setw(3) << "二" << setw(3) << "三" << setw(3) << "四" << setw(3) << "五" << setw(3) << "六" << endl; for (int i = 0; i < first; i++) cout << setw(3) << " "; for (int i = first; i < total + first; i++) { cout << setw(3) << i - first + 1; if (i == newline) { cout << endl; newline += 7; } } cout << endl; system("pause"); return 0; } |