#include <stdio.h>
#include <locale.h> //Biblioteca locale é uitlizada para definar o idioma do programa.
int main( ) {
setlocale ( LC_ALL
, "portuguese" ) ; //Comando utilizado para caracteres especiais aparecerem. int dia1, mes1, ano1;
int dia2, mes2, ano2;
printf ( "Comparador de datas \n \n " ) ;
printf ( " Digite o dia (1 a 31): " ) ; printf ( " Digite o mês (1 a 12): " ) ;
printf ( " Digite o dia (1 a 31): " ) ; printf ( " Digite o mês (1 a 12): " ) ;
// Compartivo
if ( ano1 > ano2 || ano1 == ano2 && ( mes1 > mes2 || ( mes1 == mes2 && dia1 > dia2) ) ) {
printf ( "A maior data é %d/%d/%d \n " , dia1
, mes1
, ano1
) ; } else if ( ano1 < ano2 || ano1 == ano2 && ( mes1 < mes2 || ( mes1 == mes2 && dia1 < dia2) ) ) {
printf ( "A maior data é %d/%d/%d \n " , dia2
, mes2
, ano2
) ; } else {
printf ( "As datas são iguais: %d/%d/%d \n " , dia1
, mes1
, ano1
) ; }
return 0 ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxsb2NhbGUuaD4gLy9CaWJsaW90ZWNhIGxvY2FsZSDDqSB1aXRsaXphZGEgcGFyYSBkZWZpbmFyIG8gaWRpb21hIGRvIHByb2dyYW1hLgoKaW50IG1haW4oKSB7CiAgICBzZXRsb2NhbGUoTENfQUxMLCAicG9ydHVndWVzZSIpOyAvL0NvbWFuZG8gdXRpbGl6YWRvIHBhcmEgY2FyYWN0ZXJlcyBlc3BlY2lhaXMgYXBhcmVjZXJlbS4KICAgIGludCBkaWExLCBtZXMxLCBhbm8xOwogICAgaW50IGRpYTIsIG1lczIsIGFubzI7CgogICAgcHJpbnRmKCJDb21wYXJhZG9yIGRlIGRhdGFzIFxuXG4iKTsKCiAgICBwcmludGYoIlByaW1laXJhIGRhdGEgXG4iKTsKICAgIHByaW50ZigiICAgIERpZ2l0ZSBvIGRpYSAoMSBhIDMxKTogIik7CiAgICBzY2FuZigiJWQiLCAmZGlhMSk7C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