a263.
日期差幾天
--
板橋高中練習題
| From: [58.115.238.56] |
發表日期
:
2015-05-21 12:28
#include <iostream>
int f(int, int);
int s(int, int);
int t(int, int);
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
int x, y, z, x1, y1, z1;
int sum, k;
while(cin>>x>>y>>z>>x1>>y1>>z1){
sum=0; k=0;
sum+=f(x, x1)*365;
sum+=f(y, y1)*30;
sum+=f(z, z1);
for(int i=s(x, x1);i<t(x, x1); i++){
if((i%4==0&&i%100!=0)||i%400==0)
k++;
}
for(int i=s(y, y1);i<t(y, y1); i++){
if(i<8){
if(i%2){
k++;
}
else if(i==2){
k--;
}
}
else
if(!(i%2)){
k++;
}
}
sum+=k;
cout<<sum<<endl;
}
return 0;
}
int f(int x, int y){
if(x>y){
return x-y;
}
else
return y-x;
}
int s(int x, int y){
if(x>y){
return y;
}
else
return x;
}
int t(int x, int y){
if(x>y){
return x;
}
else
return y;
}