[Resolvido] programa de HORAS
Eu estou comecando a aprender programacao e venho acompanhando seus artigos; e gostaria de tirar uma duvida sobre um programa q estou fazendo de horas, e devo imprimir o tempo dado em seg em HORAS: MINUTOS:SEGUNDOS, mas so imprime por exemplo se eu entrar com 3600 ele imprime 1:0:0 e ele deveria sair 01:00:00, qual o erro. ou seja com um zero na frente dos numeros qnd eles forem menores de 10,o programa q fiz foi:#include <iostream.h>#include <stdlib.h>#include <iomanip.h>int main(){ int TEMPO, HORAS, MIN, SEG, RESTO; cout << " Entre com tempo iniciado : "; cin >> TEMPO ; cout << "\n" ; HORAS = TEMPO / 3600 ; RESTO = TEMPO % 3600 ; MIN = RESTO / 60 ; RESTO = RESTO % 60 ; SEG = RESTO ; cout << HORAS << ":" << MIN << ":" << SEG << endl; system("PAUSE"); return 0; } eu tb tentei assim:...S = RESTO ; {if ( H > 10 && M > 10 && S > 10 ) cout << H << ":" << M << ":" << S << " " ; if ( H > 10 && M > 10 && S < 10 ) cout << H << ":" << M << ":" << "0" << S << " " ; if ( H > 10 && M < 10 && S> 10 ) cout << H << ":" << "0" << M << ":" << S << " " ; if ( H > 10 && M < 10 && S < 10 ) cout << H << ":" << "0" << M << ":" << "0" << S << " " ; if ( H < 10 && M > 10 && S > 10 ) cout << "0" << H << ":" << M << ":" << S << " " ; if ( H < 10 && M > 10 && S < 10 ) cout << "0" << H << ":" << M << ":" << "0" << S << " " ; if ( H < 10 && M < 10 && S > 10 ) cout << "0" << H << ":" << "0" << M << ":" << S << " " ; if ( H < 10 && M < 10 && S < 10 ); cout << "0" << H << ":" << "0" << M << ":" << "0" << S << " " ; }.... mas ele imprime 2 vezes e errado: se 3500, 00:58:20 00:058:020 desde ja agradeco!
Discussão (2)
Carregando comentários...