Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
- int main(){
- const int MaxSizeList = 10;
- double Nro[MaxSizeList], NroAux1, NroAux2;
- unsigned int PosArray, PosLastSmaller, CounterPos, TotalPos, LastPos, FirstPos;
- clrscr;
- Nro[0] = 8.45;
- Nro[1] = 1;
- Nro[2] = 4;
- Nro[3] = 2;
- Nro[4] = 15;
- Nro[5] = 6;
- Nro[6] = 7;
- Nro[7] = 3;
- Nro[8] = 8;
- Nro[9] = 5;
- TotalPos = (MaxSizeList - 1);
- FirstPos = 0;
- LastPos = 9;
- for(PosArray = FirstPos; PosArray < LastPos; PosArray++ ){
- NroAux1 = Nro[PosArray];
- PosLastSmaller = PosArray;
- for(CounterPos = (PosArray + 1); CounterPos <= LastPos; CounterPos++ ){
- if(NroAux1 >= Nro[CounterPos]){
- PosLastSmaller = CounterPos;
- NroAux1 = Nro[PosLastSmaller];
- }
- }
- if(PosLastSmaller > PosArray){
- for(CounterPos = PosArray; CounterPos <= LastPos; CounterPos++){
- if((CounterPos >= PosLastSmaller) && (CounterPos < LastPos)){
- NroAux2 = Nro[CounterPos + 1];
- }
- else{
- NroAux2 = Nro[CounterPos];
- }
- Nro[CounterPos] = NroAux1;
- NroAux1 = NroAux2;
- }
- }
- }
- for(CounterPos = FirstPos; CounterPos <= TotalPos; CounterPos++){
- printf("%3d : %3.2f\n",CounterPos, Nro[CounterPos]);
- }
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement