60分求助QWQ

P5690 [CSP-S2019 江西] 日期

第七行```p[1]>2```应为```p[1]>'2'```
by vvrr @ 2023-08-10 20:03:09


``` #include <cstdio> #include <cstring> #include <iostream> using namespace std; inline int read() { char c = getchar(); int x = 0, f = 1; for( ; !isdigit(c); c = getchar()) if(c == '-') f = -1; for( ; isdigit(c); c = getchar()) x = x * 10 + c - 48; return x * f; } int n, m, ans = 0; int main() { n = read(), m = read(); if(n > 12 || n == 0) ans++; if(m > 31 || ((n == 4 || n == 6 || n == 9 || n == 11)&&(m > 30)) || m == 0 || (n == 2 && m > 28)) ans++; cout << ans << '\n'; return 0; } ``` # 你参考一下喵的代码 # 你的判断就错了
by MilchstraBe @ 2023-08-10 20:06:58


```cpp #include<bits/stdc++.h> using namespace std; int main() { string p; int cnt=0; cin>>p; if(p[1]>'2'&&p[0]>'1'){ p[0]='0'; cnt++; if(p[1]>'9'){ cnt++; } } if(p[1]<'2'&&p[0]>'1'){ cnt++; } if(p[0]=='0'&&p[1]=='2'){ if(p[3]>'2'){ cnt++; } } if(p[1]!='2'&&p[3]>'3'){ cnt++; } if(p[1]!='2'&&p[3]=='3'){ if(p[4]>'0'||p[4]>'1'){ cnt++; } } cout<<cnt; return 0; } ```
by Restart_Justin @ 2023-08-17 10:22:42


还是60分,判断错了
by Restart_Justin @ 2023-08-17 10:23:21


感谢
by __Li_Chuan_Pei__ @ 2023-08-18 10:59:58


``` #include<iostream> using namespace std; int main() { char s1[6]; int a[6]; for(int i=1;i<=5;i++) { cin>>s1[i]; } a[1]=s1[1]-'0'; a[2]=s1[2]-'0'; a[3]=s1[4]-'0'; a[4]=s1[5]-'0'; int tot=0; if(a[1]*10+a[2]<=12 && (a[2]==1||a[2]==3||a[2]==5||a[2]==7||a[2]==8||a[1]==1&&a[2]==0||a[1]==1&&a[2]==2) && a[3]*10+a[4]>31)//1 3 5 7 8 10 12 { tot++; } else if(a[1]*10+a[2]<=12 && a[1]*10+a[2]!=2 && a[3]*10+a[4]>30) { tot++; } else if(a[1]*10+a[2]<=12 && a[3]*10+a[4]>28) { tot++; } if(a[1]*10+a[2]>12 && a[1]==1 && a[3]*10+a[4]<=31)//14-31 { tot++; } if(a[1]*10+a[2]>12 && a[1]>1 && a[2]<=2 && a[3]*10+a[4]<=31)//32-14 { tot++; } if(a[1]*10+a[2]>12 && a[1]>1 && a[2]>2 && a[3]*10+a[4]<=31)//34-30 { tot+=2; } if(a[1]>1 && a[2]>2 && a[3]*10+a[4]>31) { tot+=2; } cout<<tot<<endl; return 0; } ```
by Accepted_please @ 2023-08-23 10:16:29


爆搜就完事了
by Accepted_please @ 2023-08-23 10:16:44


|