Ordenamiento por el metodo de burbuja
Publicado por ivan herrera (1 intervención) el 05/05/2016 01:01:11
TENGO ESTE PROGRAMA QUE CONSISTE EN ORDENAR X CANTIDAD DE NUMEROS A TRAVES DEL METODO DE BURBUJA; SOLO QUE TIENE UN ERRO Y NO LOGRO ENCONTRARLO; ME ORDENA LOS NUMEROS EN ALGUNOS CASO, MENOS CUANDO ES MENOR A 12 Y ENTRE OTRA CANTIDAD DE NUM. GRACIAS POR RESPONDER
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <windows.h>
#include<stdio.h>
int main ()
{
int i,j,aux,c,vector[c];
i=1;
j=1;
aux=0;
printf("Escribe la cantidad de numeros que se te de la gana: ");
scanf("%i",&c);
printf("Escribe tu numeros: \n");
for (i=1;i<=c;i++){
printf("%i numero: ",i);
scanf("%i",&vector[i]);
}
for(i=1;i<=c;i++){
for(j=1;j<=c;j++){
if(vector[j]>vector[j+1]){
aux=vector[j];
vector[j]=vector[j+1];
vector[j+1]=aux;
}
}
}
printf("\n Numeros de manera ordenada: \n");
for (i=1;i<=c;i++){
printf("%i|",vector[i]);
}
return 0;
}
Valora esta pregunta
0