int alpha_list(struct seat* seats)
{
int i;
int v = 0;
int valid;
valid = SEATONPLANE - add_empty(seats, 0);
struct seat** vseat = (struct seat**)malloc(valid * sizeof(seat));
if (valid == 0)
puts("No reserved seat!");
else
{
for (i = 0;i < SEATONPLANE;i++)
{
if (seats[i].condition)
{
vseat[v] = &seats[i];
v++;
}
}
for (int a = 0;a < valid - 1;a++)
for (int b = a + 1;b < valid;b++)
if (strcmp(vseat[a]->first_name, vseat[b]->first_name) > 0)
{
struct seat* temp;
temp = vseat[a];
vseat[a] = vseat[b];
vseat[b] = temp;
}
for (i = 0;i < valid;i++)
printf("Seat %d: %s %s.\n", vseat[i]->seat_number,
vseat[i]->first_name, vseat[i]->last_name);
}
free(vseat);
return valid;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/133911.html
標籤:C語言
上一篇:用鏈表實作通訊錄 為什么他只能執行到輸入地址下面不執行了
下一篇:c語言字串問題
