TEMA

Answer error 5%

David T. Ramírez preguntado 10 months ago

Please!! I need help, I don't get find the error...

#include <iostream>

int main (){

int total {} ; // en dias
std::cin >> total ;
int year {}, month {}, day {};

year = total / 365 ;
month = (total / 30)%12 ;
day = (total % 365)%30 ;

std::cout<<year<<" ano(s)\n";
std::cout<<month<<" mes(es)\n";
std::cout<<day<<" dia(s)\n"; 

return 0;

}

Recuerda no enviar soluciones. Tu mensaje puede ser revisado por nuestros moderadores.

  • CSE_19_Masrafi Bin Seraj respondido 10 months ago

    You have a bug on the 10th line calculating month.

    change this line:

    month = (total / 30)%12 ;

    To:

    month = (total % 365 )/30 ;