编程题

完善程序: (打印月历)输入月份 m(1≤m≤12),按一定格式打印 2015 年第 m 月的月历。 (第三、四空 2.5 分,其余 3 分)

例如,2015 年 1 月的月历打印效果如下(第一列为周日):


#include <iostream>

#include <string>


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()

{

cin >> m;

cout << "S\tM\tT\tW\tT\tF\tS" << endl;  //'\t'为 TAB 制表符

                         ⑴        ;

for(i = 1; i < m; i++)

offset =      ⑵      ;

for(i = 0; i < offset; i++)

cout << '\t';

for(i = 1; i <=     ⑶     ; i++)

{

cout <<    ⑷    ;

if(i == dayNum[m] ||    ⑸   == 0)

cout << endl;

else

cout << '\t';

}

return 0;

}

查看答案
赣ICP备20007335号-2