Merge branch 'fixinput' of UBB/sort into master
This commit is contained in:
commit
e3f5691462
@ -179,12 +179,12 @@ int main (int argc, char **argv) {
|
|||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
if (elegir) {
|
if (elegir) {
|
||||||
opt = 0;
|
opt = 0;
|
||||||
while (opt <= 1) {
|
|
||||||
fprintf(stdout, "Elegir elemento %lli: ", i + 1);
|
fprintf(stdout, "Elegir elemento %lli: ", i + 1);
|
||||||
fscanf(stdin, "%d", &opt);
|
while (!fscanf(stdin, "%d", &opt)) {
|
||||||
if (opt <= 1) {
|
// Falló, pide de nuevo después de limpiar stdin
|
||||||
|
while ((opt = getchar()) != '\n' && opt != EOF) { }
|
||||||
fprintf(stdout, "Número invalido! Tiene que ser mayor de 1!\n");
|
fprintf(stdout, "Número invalido! Tiene que ser mayor de 1!\n");
|
||||||
}
|
fprintf(stdout, "Elegir elemento %lli: ", i + 1);
|
||||||
}
|
}
|
||||||
array[i] = opt;
|
array[i] = opt;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user