Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.
/**Bismillahir Rahmanir Rahim**/ #include <stdio.h> int main() { int month, day, x, i; int ara[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 25}; while(scanf("%d%d", &month, &day) != EOF) { if(month == 12 && day == 25) printf("E natal!\n"); else if(month == 12 && day > 25) printf("Ja passou!\n"); else if(month == 12 && day == 24) printf("E vespera de natal!\n"); else { x = ara[month-1] - day; for(i = month; i < 12; i++) x += ara[i]; printf("Faltam %d dias para o natal!\n", x); } } return 0; }
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeletethis is not URI 2136...this is URI 2139
ReplyDeleteThank You!! Updated!!!
DeleteQual é o erro do meu codigo?
ReplyDelete#include
#include
int main()
{
int mes = 0;
int dia = 0;
while(scanf("%d %d",&mes,&dia) != EOF){
if( mes == 12){
if( dia == 24 )
printf("E vespera de natal!\n");
if( dia == 25 )
printf("E natal!\n");
if( dia > 25 )
printf("Ja passou!\n");
if( dia <= 23 ){
printf("Faltam %d dias para o natal!\n",(( 25 - dia ) ));
}
}
if( mes == 11 ){
printf("Faltam %d dias para o natal!\n",( (12 - mes) * 30 + ( 25 - dia ) ));
}
if( mes <= 10 ){
printf("Faltam %d dias para o natal!\n",( (12 - mes) * 30 + ( 30 - dia ) ));
}
}
return 0;
}