Created
June 15, 2024 02:05
-
-
Save diazvictor/193fa72c929e472dc5e4a95c487fa90a to your computer and use it in GitHub Desktop.
Conversor de Segundos a Horas, Minutos y Segundos en C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
void tiempo(int segundos, int& horas, int& min, int& seg) { | |
// Calcular las horas | |
horas = segundos / 3600; | |
// Calcular los minutos | |
segundos %= 3600; | |
min = segundos / 60; | |
// Calcular los segundos | |
segundos %= 60; | |
seg = segundos; | |
} | |
int main() { | |
int segundos, horas, min, seg; | |
// Solicitar al usuario el número de segundos | |
cout << "Ingrese el número de segundos: "; | |
cin >> segundos; | |
// Convertir segundos a horas, minutos y segundos | |
tiempo(segundos, horas, min, seg); | |
// Mostrar el resultado | |
cout << horas << " hora(s), " << min << " minuto(s), " << seg << " segundo(s)." << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment