Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool validarFecha(int dia, int mes, int anio)
- {
- if (dia<=0 || mes<=0) return false;
- switch(mes)
- {
- case 1:
- case 3:
- case 5:
- case 7:
- case 8:
- case 10:
- case 12:
- if(dia>31) return false;
- break;
- case 4:
- case 6:
- case 9:
- case 11:
- if(dia>30) return false;
- break;
- case 2:
- if(esBisiesto(anio))
- {
- if(dia>29) return false;
- }
- else
- {
- if(dia>28) return false;
- }
- break;
- default:
- return false;
- }
- if(anio<0) return false;
- return true;
- }
- bool esBisiesto(int anio)
- {
- if(anio%4==0)
- {
- if(anio%100==0 && anio%400!=0) return false;
- else return true;
- }
- else return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement