Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
A_141212_OrdenarArray
//Titulo del ejersisioh #include <stdio.h> #include <stdlib.h> #include <time.h> #define _T 100 void mostrarArray(long tam , short a[tam]); void darValorAleatorioArray (long tam, short a[tam], short lI, short lS); void ordenarArray(long tam, short a[tam]); void intercambiar(short*a, short*b); double calculoMediaArray(long tam, short a[tam]); int main(void) { short array[_T]; short lInf, lSup; printf("Límite inferior: "); scanf(" %hd", &lInf); printf("Límite superior: "); scanf(" %hd", &lSup); darValorAleatorioArray(_T, array, lInf, lSup); mostrarArray(_T, array); printf("\n\n"); ordenarArray(_T, array); mostrarArray(_T, array); double media = calculoMediaArray(_T, array); printf("\n\n\nLa media es: %.2lf\n", media); printf("\n\n"); return 0; } void mostrarArray(long tam , short a[tam]) { long i; for(i = 0 ; i < tam ; i++) { if(i % 5 == 0) printf("\n"); printf("%8hd", a[i]); } return; } void darValorAleatorioArray (long tam, short a[tam], short lI, short lS) { long i; for(srand(time(NULL)), i = 0 ; i < tam ; i++) { a[i] = lI + rand() % (lS - lI + 1); } return; } void ordenarArray(long tam, short a[tam]) { long i, j; for(i = 0 ; i < tam ; i++) { for(j = i + 1 ; j < tam ; j++) { if(a[i] > a[j]) { intercambiar(&a[i], &a[j]); } } } return; } void intercambiar(short*a, short*b) { short aux = *a; *a = *b; *b = aux; return; } double calculoMediaArray(long tam, short a[tam]) { double suma; long i; for(suma = 0 ,i = 0 ; i < tam ; i++) { suma += a[i]; } return; }
run
|
edit
|
history
|
help
0
co_assign1_ques_4
Tree
armstrong number using a while loop
alphabet2 pyramid right
FILE Access 2
c. new one
AVANCE PREGUNTA 3 FICHEROS
signaling NaN test
romitk
Lior Yehieli Lesson