Solucionar edge-case en el que el primer numero es mayor al segundo

This commit is contained in:
PC de clase committed 2026-10-05 10:04:29 +02:00
1 parent 2faefaef88
commit 844ec651a1
1 file changed
+5 -2
+5 -2
View File
@@ -11,7 +11,10 @@ void main() {
int n2 = sc.nextInt();
sc.close();
while(n1 <= n2)
System.out.printf("%d, ", n1++);
int mayor = Math.max(n1, n2);
int menor = Math.min(n1, n2);
while(menor <= mayor)
System.out.printf("%d, ", menor++);
System.out.println();
}