Created
October 6, 2020 12:17
-
-
Save Michaelkodji/127c4871d77a298559f5a1ac1a2bb50d to your computer and use it in GitHub Desktop.
Nombres de jours séparant deux date sous la forme 11/mm/aaaa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include<cmath.> | |
using namespace std; | |
typedef struct DATE | |
{ | |
int J,M,A; | |
}; | |
bool bissectile(DATE d) | |
{ | |
if((d.A%400==0)||((d.A%100!=0)&&(d.A%4==0))) | |
return true; | |
else | |
return false; | |
} | |
long int quantieme (DATE d) | |
{ | |
int MOIS[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; | |
int q=0; | |
DATE D; | |
D.J=1,D.M=1; | |
for(D.A=1900; D.A<=d.A-1;D.A++) | |
{ | |
if(bissectile(D)==true) | |
{ | |
q++; | |
} | |
} | |
q=q+365*(d.A-1901); | |
for(int i=0;i<=d.M-1;i++) | |
{ | |
q=q+MOIS[i]; | |
} | |
if(bissectile(d)==true) | |
{ | |
q=q+1+d.J; | |
} | |
else | |
{ | |
q=q+d.J; | |
} | |
return q; | |
} | |
int difference (DATE d1, DATE d2) | |
{ | |
return(fabs(quantieme(d1)-quantieme(d2))); | |
} | |
int main() | |
{ | |
DATE D1,D2; | |
cout<<"Ce programme a ete ecrit par Michael KODJI"<<endl; | |
cout<<"Entrez une date J M A:"<<endl; | |
cin>>D1.J>>D1.M>>D1.A; | |
cout<<"Entrez une autre date J M A:"<<endl; | |
cin>>D2.J>>D2.M>>D2.A; | |
cout<<"\n"; | |
D1.J=31;D1.M=7;D1.A=2005; | |
D2.J=17;D1.M=12;D2.A=2019; | |
D1.J=31;D1.M=7;D1.A=2005; | |
D2.J=17;D1.M=12;D2.A=2019; | |
cout << "Difference=" <<difference(D1,D2)<<" Jours"<< endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment