文章

20

粉丝

0

获赞

35

访问

1.0k

头像
日期计算 题解:
P1051 中南大学机试题
发布于2026年3月13日 17:41
阅读数 61

#include<bits/stdc++.h>
using namespace std;

struct{
    int y, m, d;
}t;
int m_d[] = {0, 31, 28, 31, 30,
             31, 30, 31, 31,
             30, 31, 30, 31};

int main(){
    while(cin >> t.y >> t.m >> t.d){
        int day = 0;
        if(t.m < 1 || t.m > 12)
            cout << "Input error!" << endl;
        else if(t.d <= 1 || t.d > 31)
            cout << "Input error!" << endl;
        else if(t.m == 2 && (t.d > 28))
            cout << "Input error!" << endl;
  ...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发