mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-22 13:31:21 +03:00
modify heapsort
This commit is contained in:
parent
04527dfc56
commit
bb6582f12b
@ -6,7 +6,6 @@ void heap_sort(int *unsorted, int n);
|
|||||||
int main() {
|
int main() {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
char s[50];
|
|
||||||
char oper;
|
char oper;
|
||||||
|
|
||||||
int* unsorted;
|
int* unsorted;
|
||||||
@ -15,13 +14,9 @@ int main() {
|
|||||||
unsorted = (int*)malloc(sizeof(int) * n);
|
unsorted = (int*)malloc(sizeof(int) * n);
|
||||||
while (getchar() != '\n');
|
while (getchar() != '\n');
|
||||||
printf("Enter numbers separated by a comma:\n");
|
printf("Enter numbers separated by a comma:\n");
|
||||||
gets(s);
|
while (i != n) {
|
||||||
|
scanf("%d,", (unsorted + i));
|
||||||
char *ptr = strtok(s, ",");
|
|
||||||
while (ptr != NULL && i < n) {
|
|
||||||
*(unsorted + i) = atoi(ptr);
|
|
||||||
i++;
|
i++;
|
||||||
ptr = strtok(NULL, ",");
|
|
||||||
}
|
}
|
||||||
heap_sort(unsorted, n);
|
heap_sort(unsorted, n);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user