There is a program that converts from seconds to hours, minutes, seconds.

#include <stdio.h> main() { // cor do cmd (verde) system("color 2"); // variaveis decimais int vremya, chasi, minuti, secundi; printf("Vvedite vremya v secundah: "); scanf("%i", &vremya); // calculos chasi = vremya / 3600; minuti = vremya * 60; secundi = vremya; // apresenta os resultados printf("\nVremya: %i:%i.%i\t ", chasi, minuti, secundi); // pause system("PAUSE"); } 

But the program writes the wrong numbers, help solve. I do not know what to lean.

  • @extazys; To format a code, select it with the mouse and click on the {} button of the editor. - stanislav

1 answer 1

 hr = s/60/60; //пересчитываем секунды в часы mn = s/60; //пересчитываем секунды в минуты sc = s%60; //остаток от деления в секундах printf("\nTime: %i:%i.%i\t ", hr , mn , sc); 
  • one
    Something tells me that for a value of 7270, the author wants to see 2 hours, 1 minute and 10 seconds, not 2 hours, 121 minutes and 10 seconds. mn = (s - hr * 3600) / 60; Although, the question is formulated so that it can be understood in different ways. - avp
  • Thank you for your help! I think it will not be useful for me alone - extazys