Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
ultimo cuestionario
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
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
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#include <stdio.h> #include <stdlib.h> void poblar(int *,int); void mediana(int *,int); int compara (const void *, const void *); int main(){ int cValores; int *valores = NULL; do{ do{ scanf("%d",&cValores); }while(cValores>25000); if(cValores==0) break; valores = (int *)realloc(valores,sizeof(int)*cValores); poblar(valores,cValores); qsort(valores,cValores,sizeof(int),compara); mediana(valores,cValores); }while(1); } void poblar(int *valores,int cValores){ int i; int valor; for(i=0;i<cValores;i++){ scanf("%i",&valor); valores[i]=valor; } } int compara (const void *pivote, const void *elemento) { int *contenidoPivote = (int *) pivote; int *contenidoElemento = (int *) elemento; if (*contenidoPivote > *contenidoElemento) return 1; else return 0; } void mediana(int *valores,int cValores){ int mediana; if(cValores%2==0){ mediana=(valores[cValores/2] + valores[cValores/2 - 1]); }else{ mediana=valores[cValores / 2]*2; } printf("%i\n",mediana); }
gcc
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
edit mode
|
history
|
discussion