美文网首页
打印某个月的月历

打印某个月的月历

作者: Roc_J | 来源:发表于2016-07-11 22:11 被阅读0次
    #include <iostream>
    #include <iomanip>
    using namespace std;
    int main(void)
    {
        int days,week;
        cout << "Please input the days and week:" << endl;
        cin >> days >> week;
        if(days<28 || days>31) cout << "Error days!" << endl;
        if(week<1 || week>7) cout << "Error week!" << endl;
        cout << " MON TUE WED THU FRI SAT SUN" << endl;
        cout << " ===========================" << endl;
        for(int i=1; i<week; i++) cout << setw(4) << " ";
        for(i=1; i<=days; i++)
        {
            cout << setw(4) << i;
            if((i+week-1)%7==0) cout << endl;
        }
        cout << endl << " ===========================" << endl;
        return 0;
    }
    

    相关文章

      网友评论

          本文标题:打印某个月的月历

          本文链接:https://www.haomeiwen.com/subject/yjpjjttx.html