Run Code
|
Code Wall
|
Users
|
Misc
|
Feedback
|
About
|
Login
|
Theme
|
Privacy
B_141212_OrdenarArray
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//Title of this code #include <stdio.h> #include <stdlib.h> #include <time.h> #define _T 100 void mostrarArray(long tam , short a[tam]); void rellenarAleatoriosArray (long tam, short a[tam], short lI, short lS); void ordenarValoresArray(long tam , short a[tam]); void intercambiar(short*x, short*y); double calculoMediaValoresArray(long tam, short a[tam]); int main(void) { short array[_T]; rellenarAleatoriosArray(_T, array, 1000, 2000); mostrarArray(_T, array); printf("\n\n"); ordenarValoresArray(_T, array); mostrarArray(_T, array); double media = calculoMediaValoresArray(_T, array); printf("\n\tLa media es %.2lf\n\n", media); 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 rellenarAleatoriosArray (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 ordenarValoresArray(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*x, short*y) { short aux = *x; *x = *y; *y = aux; return; } double calculoMediaValoresArray(long tam, short a[tam]) { double suma; long i; for(suma = i = 0 ; i < tam ; i++) { suma += a[i]; } return suma / tam; }
gcc
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 0.22 sec, absolute running time: 0.13 sec, cpu time: 0 sec, memory peak: 3 Mb, absolute service time: 0.36 sec
fork mode
|
history
|
discussion