資料結構實驗之鍊表六 有序鍊錶的建立

2021-08-09 12:02:08 字數 1107 閱讀 6114

problem description

輸入n個無序的整數,建立乙個有序鍊錶,鍊錶中的結點按照數值非降序排列,輸出該有序鍊錶。

input

第一行輸入整數個數n;

第二行輸入n個無序的整數。

output

依次輸出有序鍊錶的結點值。

example input

6

33 6 22 9 44 5

example output

5 6 9 22 33 44

hint

不得使用陣列!

#include#include#include#define error -1

#define overflow -2

#define ok 1

typedef int elemtype;

typedef int statu;

typedef struct lnode

link;

link * creat(int n);

link * negative(link *head);

statu dis_link(link *head);

statu split(link *head);

int main()

link *creat(int n)

if(q -> data < p -> data)

q -> next = p;

else}}

return head;

}link * negative(link *head)

}return head;

}statu dis_link(link *head)

printf("%d\n", p -> data);

return ok;

}statu split(link *head)

else

r = r -> next;

}printf("%d %d\n", k, j);

dis_link(head2);

dis_link(head1);

return ok;

}

資料結構實驗之鍊表六 有序鍊錶的建立

time limit 1000ms memory limit 65536k 輸入n個無序的整數,建立乙個有序鍊錶,鍊錶中的結點按照數值非降序排列,輸出該有序鍊錶。第一行輸入整數個數n 第二行輸入n個無序的整數。依次輸出有序鍊錶的結點值。6 33 6 22 9 44 5 5 6 9 22 33 44 ...

資料結構實驗之鍊表六 有序鍊錶的建立

資料結構實驗之鍊表六 有序鍊錶的建立 time limit 1000ms memory limit 65536k 輸入n個無序的整數,建立乙個有序鍊錶,鍊錶中的結點按照數值非降序排列,輸出該有序鍊錶。第一行輸入整數個數n 第二行輸入n個無序的整數。依次輸出有序鍊錶的結點值。6 33 6 22 9 4...

資料結構實驗之鍊表六 有序鍊錶的建立

time limit 1000ms memory limit 65536k 題目描述 輸入n個無序的整數,建立乙個有序鍊錶,鍊錶中的結點按照數值非降序排列,輸出該有序鍊錶。輸入 第一行輸入整數個數n 第二行輸入n個無序的整數。輸出 依次輸出有序鍊錶的結點值。示例輸入6 33 6 22 9 44 5 ...