Comprobar HMS

This commit is contained in:
PC de clase committed 2026-09-28 10:16:23 +02:00
1 parent d459661d0a
commit 7af7a01592
1 file changed
+5 -2
+5 -2
View File
@@ -11,7 +11,11 @@ void main() {
h = sc.nextInt(); h = sc.nextInt();
m = sc.nextInt(); m = sc.nextInt();
s = sc.nextInt(); s = sc.nextInt();
s ++; if (h >= 24 || m >= 60 || s >= 60){
System.out.println("Error: Hora inválida");
return;
}
s++;
// Espagueti máximo xd // Espagueti máximo xd
if(s > 59){ if(s > 59){
s = 0; s = 0;
@@ -20,7 +24,6 @@ void main() {
m = 0; m = 0;
h++; h++;
if(h > 23){ if(h > 23){
m = 0;
h = 0; h = 0;
} }
} }