Advertisement
easy_code_noobs

P58459 - Dates vàlides

Oct 10th, 2015
477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. bool es_data_valida (int x, int y, int z) {
  5.     bool traspas;
  6.    
  7.     if ((z%100 == 0 and (z/100)%4 == 0) or (z%4 == 0 and z%100 != 0)) traspas = true;
  8.     else traspas = false;
  9.    
  10.     if (x > 31 or y > 12 or x < 1 or y <1) return false;
  11.     else if (y == 2 and (x > 29 or (x == 29 and not traspas))) return false;
  12.     else if (x == 31 and (y == 2 or y == 4 or y == 6 or y == 9 or y == 11)) return false;
  13.     else return true;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement