Advertisement
alex_doan_

Untitled

Dec 10th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. bool checkLeapYear(int year){
  6. if(year<0){
  7. return false;
  8. }
  9. else if(year % 400 == 0){
  10. return true;
  11. }
  12. else if(year % 100 == 0){
  13. return false;
  14. }
  15. else if(year % 4 == 0){
  16. return true;
  17. }
  18. return false;
  19. }
  20.  
  21. int main() {
  22. int inputYear;
  23. cin>>inputYear;
  24. if(checkLeapYear(inputYear)){
  25. cout<<inputYear<<" is a leap year."<<endl;
  26. }
  27. else{
  28. cout<<inputYear<<" is not a leap year."<<endl;
  29. }
  30.  
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement