This commit is contained in:
2025-04-16 17:16:08 +02:00
commit d7cccb791a
11 changed files with 356 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
#include <stdio.h>
#include <stdlib.h>
// Capture the pipe of array contents, first number is the size
int main() {
int s;
scanf("%d", &s);
int *array = malloc(sizeof(int) * s);
for (int i = 0; i < s; i++) {
scanf("%d", &array[i]);
}
for (int j = 1; j < s; j++) {
int key = array[j];
int i = j - 1;
while (i >= 0 && array[i] > key) {
array[i + 1] = array[i];
i -= 1;
}
array[i + 1] = key;
}
free(array);
return 0;
}