Danut
unknown
c_cpp
4 years ago
786 B
3
Indexable
#include <stdio.h> #define lungime 10 int main() { int array[lungime] = { 20, 9, 5, 7, 60, 5, 3, 4, 33, 1 }; //int i = 1; //while (i < lungime) { // int j = i; // while (j > 0 && array[j - 1] > array[j]) { // int aux = array[j]; // array[j] = array[j - 1]; // array[j - 1] = aux; // j--; // } // i++; //} int i = 1; do { int j = i; while (j > 0 && array[j - 1] > array[j]) { int aux = array[j]; array[j] = array[j - 1]; array[j - 1] = aux; j--; } i++; } while (i < lungime); i = 0; while (i < lungime) { printf("%d ", array[i]); i++; } }
Editor is loading...