编程题
完善程序: (打印月历)输入月份 m(1≤m≤12),按一定格式打印 2015 年第 m 月的月历。 (第三、四空 2.5 分,其余 3 分)
例如,2015 年 1 月的月历打印效果如下(第一列为周日):
#include
#include
using namespace std;
const int dayNum[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int m, offset, i;
int main()
\t{
\t\tcin >> m;
\t\tcout << "S\\tM\\tT\\tW\\tT\\tF\\tS" << endl; //'\\t'为 TAB 制表符
\t ⑴ ;
\t\tfor(i = 1; i < m; i )
\t\t\toffset = ⑵ ;
\t\tfor(i = 0; i < offset; i )
\t\t\tcout << '\\t';
\t\tfor(i = 1; i <= ⑶ ; i )
\t\t\t{
\t\t\t\tcout << ⑷ ;
\t\t\t\tif(i == dayNum[m] || ⑸ == 0)
\t\t\t\t\tcout << endl;
\t\t\t\telse
\t\t\t\t\tcout << '\\t';
\t\t\t}
\t\treturn 0;
\t}
发表评论 取消回复