3 条题解
-
0仲昱腾 LV 7 @ 2023-11-25 11:18:33
#include<bits/stdc++.h>
using namespace std;
int d1,d2,d3,d4;
int month(int k)
{
if(k==1||k==3||k==5||k==7||k==8||k==10||k==12)
return 31;
else if(k==4||k==6||k==9||k==11)
return 30;
else if(k==2)
return 28;
}
int tianshu(int d1,int d2,int d3,int d4)
{
int p1=month(d1)-d2;
int ans=0;
if(d3-d1==0) return d4-d2;
else if(d3-d1==1) return p1+d4;
else if(d3-d1!=0||d3-d1!=1)
{
for(int i=d1+1;i<=d3-1;i++)
{
ans+=month(i);
}
return (month(d1)-d2)+ans+d4;
}
}
int main()
{
cin>>d1>>d2>>d3>>d4;
cout<<tianshu(d1,d2,d3,d4);
return 0;
} -
02022-05-09 19:37:50@
#include<bits/stdc++.h>
using namespace std;int main()
{
int n,n1,a,b,s=0,s1=0;
cin>>n>>a>>n1>>b;
switch(n)
{
case 1:s+=a;break;
case 2:s=s+a+31;break;
case 3:s=s+a+59;break;
case 4:s=s+a+90;break;
case 5:s=s+a+120;break;
case 6:s=s+a+151;break;
case 7:s=s+a+181;break;
case 8:s=s+a+212;break;
case 9:s=s+a+243;break;
case 10:s=s+a+273;break;
case 11:s=s+a+304;break;
case 12:s=s+a+334;break;
}
switch(n1)
{
case 1:s1+=b;break;
case 2:s1=s1+b+31;break;
case 3:s1=s1+b+59;break;
case 4:s1=s1+b+90;break;
case 5:s1=s1+b+120;break;
case 6:s1=s1+b+151;break;
case 7:s1=s1+b+181;break;
case 8:s1=s1+b+212;break;
case 9:s1=s1+b+243;break;
case 10:s1=s1+b+273;break;
case 11:s1=s1+b+304;break;
case 12:s1=s1+b+334;break;
}
cout<<s1-s;
return 0;
} -
-92021-12-17 19:26:12@
#include <iostream> using namespace std; int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; int main() { int month,day,zhongjiancha,cha;cin>>month>>day; int month1,day1;cin>>month1>>day1; int benyuecha=a[month]-day; if(month+1==month1) { cha=a[month]-day; cout<<cha+day1; } if(month==month1) cout<<day1-day; if(month+1!=month1&&month!=month1) { for(int i=month+1;i<month1;i++) zhongjiancha+=a[i]; cout<<zhongjiancha+benyuecha+day1; } return 0; }
- 1
信息
- ID
- 1036
- 难度
- 4
- 分类
- (无)
- 标签
- 递交数
- 143
- 已通过
- 61
- 通过率
- 43%
- 上传者