这样做有反例
比如"04-31" "06-31"需要改1次,但是输出只会输出0
by _3247535661_ @ 2024-02-02 14:02:11
没有判断大月小月
by _3247535661_ @ 2024-02-02 14:03:34
@[jiangyunuo](/user/1061050)
by ZBXALQX @ 2024-02-02 14:04:20
```
#include<bits/stdc++.h>
using namespace std;
int month,day;
int main(){
string a;
cin>>a;
month=int(a[0]-'0')*10+int(a[1]-'0');
day=int(a[3]-'0')*10+int(a[4]-'0');
if(day>0 and day<=28){
if(month>0 and month<=12)cout<<0;
else cout<<1;
}
else if(day==29 or day==30){
if(month==2 or month==0 or month>12)cout<<1;
else cout<<0;
}
else if(day==31){
if(month==1 or month==3 or month==5 or month==7 or month==8 or month==10 or month==12)cout<<0;
else if(month==2 or month==4 or month==6 or month==9 or month==11 or (month>=13 and month<=19))cout<<1;
else if(month%10==4 or month%10==6 or month%10==9)cout<<2;
else cout<<1;
}
else if(month==0 or month>12)cout<<2;
else cout<<1;
return 0;
}
多加几个判断条件就行了
by _3247535661_ @ 2024-02-02 14:17:02
@[_3247535661_](/user/1040109) 谢谢,已关
by jiangyunuo @ 2024-02-02 14:23:01