¿Como hago un arreglo para que lea 10 numeros y imprima cual es el mayor y cual es el menor de todos ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

¿Como hago un arreglo para que lea 10 numeros y imprima cual es el mayor y cual es el menor de todos ?

19th Apr 2017, 11:01 PM
Obed Vargas
Obed Vargas - avatar
4 Answers
+ 4
haz un ciclo for que recorra el arreglo algo así: may = -999999999; min = 999999999; for( i=1; i<=10; i++){ if( arreglo[i] > may){ may=arreglo [i]; indice_may = i; } if( arreglo[i] < min){ min=arreglo [i]; indice_min = i; } }
19th Apr 2017, 11:23 PM
⏩▶Clau◀⏪
⏩▶Clau◀⏪ - avatar
+ 2
si, claro se puede hacer con un for o con un while may = -999999999; min = 999999999; i=1; while( i<=10){ if( arreglo[i] > may){ may=arreglo [i]; indice_may = i; } if( arreglo[i] < min){ min=arreglo [i]; indice_min = i; } i++; }
20th Apr 2017, 12:49 AM
⏩▶Clau◀⏪
⏩▶Clau◀⏪ - avatar
0
y con for seria igual..?
20th Apr 2017, 12:38 AM
Obed Vargas
Obed Vargas - avatar
0
ok.. muchas gracias😊😊
20th Apr 2017, 1:03 AM
Obed Vargas
Obed Vargas - avatar