Skip to content

Instantly share code, notes, and snippets.

@gabrielcesar
Last active August 5, 2016 01:50
Show Gist options
  • Save gabrielcesar/00ace0bae057441ea08e5b22d76c558b to your computer and use it in GitHub Desktop.
Save gabrielcesar/00ace0bae057441ea08e5b22d76c558b to your computer and use it in GitHub Desktop.
/*
* q-04.c
*/
#include <stdio.h>
int main ( void )
{
int dia, mes, ano;
scanf ( "%d/%d/%d", &dia, &mes, &ano );
if ( ( dia >= 1 && dia <= 31 ) && ( mes >= 1 && mes <= 12 ) && ( ano >= 1500 && ano <= 3000 ))
{
if ( ( dia == 29 && mes == 2 ) && ( ano % 4 == 0 && ( ano % 400 == 0 || ano % 100 != 0 )))
printf ("A data é válida.\n" );
if ( dia <= 28 && mes == 2 )
printf ("A data é válida.\n" );
if ( ( dia <= 30 ) && ( mes == 4 || mes == 6 || mes == 9 || mes == 11 ))
printf ("A data é válida.\n" );
if ( ( dia <= 31 ) && (mes == 1 || mes == 3 || mes == 5 || mes == 7 || mes ==8 || mes == 10 || mes == 12 ))
printf ( "A data é válida.\n" );
else
printf ( "A data é inválida.\n" );
}
else
printf ("A data é inválida.\n" );
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment