Created
October 6, 2020 12:08
-
-
Save Michaelkodji/7a13c997ab1ced63f9ab92be9c3f1d47 to your computer and use it in GitHub Desktop.
Année bissextile
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> | |
using namespace std; | |
int i=0, an; int mois_entre; | |
typedef struct date{ | |
int j,m,a; | |
}; | |
bool anneeBissextile(int an){ | |
bool bissextile; | |
bissextile=((an % 400==0)|| ((an % 4==0) && (an % 100!=0))); | |
if(bissextile){ | |
bissextile=true; | |
//cout<<"lannee est bissextile"<<endl; | |
} | |
else{ | |
bissextile=false; | |
//cout<<"l'annee n'est pas bissextile"<<endl; | |
} | |
return bissextile; | |
} | |
int mois_complet(int mois,int an){ | |
int jour_mois; | |
if (mois==2){ | |
if(anneeBissextile(an)==true){ | |
jour_mois=29; | |
//cout<<jour_mois<<endl;; | |
} | |
else{ | |
jour_mois=28; | |
//cout<<jour_mois<<endl; | |
} | |
} | |
else if(mois<=7){ | |
if(mois%2!=0) | |
jour_mois=31; | |
else | |
jour_mois=30; | |
} | |
else{ | |
if(mois%2==0) | |
jour_mois=31; | |
else | |
jour_mois=30; | |
} | |
return jour_mois; | |
} | |
int main() | |
{ | |
date d; | |
/*cout << "Entrer l'annee:" << endl; | |
cin>>an; | |
anneeBissextile(an); | |
cout<<"Entrer le numero du mois"<<endl; | |
cin>>mois_entre; | |
mois_complet(mois_entre,an);*/ | |
cout<<"Entrer le jour"<<endl; | |
cin>>d.j; | |
cout<<"Entrer le mois"<<endl; | |
cin>>d.m; | |
cout<<"Entrer l'annee"<<endl; | |
cin>>d.a; | |
if(d.j < mois_complet(d.m,d.a)){ | |
++d.j; | |
cout<<d.j<<"/"<<d.m<<"/"<<d.a<<endl; | |
} | |
else{ | |
d.j=1; | |
if(d.m<12){ | |
++d.m;} | |
else{ | |
d.m=1; | |
++d.a;} | |
cout<<d.j<<"/"<<d.m<<"/"<<d.a<<endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment