void sort(Info* head) { int size = getHouseholdInfoSize(head); int index = 0; Info** arr = (Info**)malloc(sizeof(Info*) * size); Info* p = head; while (p) { arr[index++] = p; p = p->next; } for (int i = 0; i < size - 1; ++i) { for (int j = i; j < size; ++j) { if (arr[i]->payablePrice < arr[j]->payablePrice) { Info* tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; } } } printTitle(); for (int i = 0; i < size; ++i) { printInfo(arr[i]); } }画一个这个函数的流程图
时间: 2024-01-22 16:03:37 浏览: 64
sort函数的具体用法
以下是sort函数的流程图:
```
(head)
|
v
[size = getHouseholdInfoSize(head)]
|
v
[arr = (Info**)malloc(sizeof(Info*) * size)]
|
v
(p = head)
|
v
[arr[index++] = p;]
|
v
[p = p->next;]
|
v
[for (int i = 0; i < size - 1; ++i)]
|
v
[for (int j = i; j < size; ++j)]
|
v
[if (arr[i]->payablePrice < arr[j]->payablePrice)]
|
v
[swap arr[i] and arr[j]]
|
v
[printTitle(); printInfo(arr[i])]
```
阅读全文