アルゴリズムとデータ構造 補足資料11-4 「第11回問題の動作」 横浜国立大学 理工学部 数物・電子情報系学科 富井尚志 int main(void) { struct list *listptr, *new1, *new2; listptr = get_list( ); print_list( listptr ); new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); new2 print_list( listptr ); return 0; } listptr new1 void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } void func2(struct list *x, struct list *p) { struct list tmp; tmp = *x; *x = *p; *p = tmp; p->next = x->next; } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> int main(void) { struct list *listptr, *new1, *new2; void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } listptr = get_list( ); print_list( listptr ); void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); new2 print_list( listptr ); } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> new1 return 0; } listptr key next 6 key next 5 key next 4 key next 3 key next 2 key 1 next NULL int main(void) { struct list *listptr, *new1, *new2; void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } listptr = get_list( ); print_list( listptr ); void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); new2 print_list( listptr ); } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> new1 return 0; } listptr key next 6 key next 5 key next 4 key next 3 key next 2 key 1 next NULL int main(void) { struct list *listptr, *new1, *new2; void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } listptr = get_list( ); print_list( listptr ); void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); new2 print_list( listptr ); } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> new1 return 0; key } next listptr key next 6 key next 5 key next 4 key next 3 key next 2 key 1 next NULL int main(void) { struct list *listptr, *new1, *new2; void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } listptr = get_list( ); print_list( listptr ); void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); new2 print_list( listptr ); } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> new1 return 0; key } 222 next listptr key next 6 key next 5 key next 4 key next 3 key next 2 key 1 next NULL int main(void) { struct list *listptr, *new1, *new2; void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } listptr = get_list( ); print_list( listptr ); void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); new2 print_list( listptr ); } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> new1 return 0; key } 222 next listptr key next 6 key next 5 key next 4 key next 3 key next 2 key 1 next NULL int main(void) x { struct list *listptr, *new1, *new2; void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } p listptr = get_list( ); print_list( listptr ); void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); new2 print_list( listptr ); } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> new1 return 0; key } 222 next listptr key next 6 key next 5 key next 4 key next 3 key next 2 key 1 next NULL int main(void) x { struct list *listptr, *new1, *new2; void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } p listptr = get_list( ); print_list( listptr ); void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); new2 print_list( listptr ); } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> new1 return 0; key } 222 next listptr listptr listptr->next key next 6 key next listptr->next->next listptr->next->next->next 5 key next 4 key next 3 key next 2 key 1 next NULL int main(void) x { struct list *listptr, *new1, *new2; void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } p listptr = get_list( ); print_list( listptr ); void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); print_list( listptr ); } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> return 0; key } 222 next key next 6 key next 5 key next 4 key next 3 key next 2 key 1 next NULL int main(void) x { struct list *listptr, *new1, *new2; void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } p listptr = get_list( ); print_list( listptr ); void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); print_list( listptr ); } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> return 0; key } next p p->next key next 6 key next 5 key next 4 key next 222 3 p->next->next key next 2 key 1 next NULL int main(void) x { struct list *listptr, *new1, *new2; void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } p listptr = get_list( ); print_list( listptr ); void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); print_list( listptr ); } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> return 0; key } 222 next key next 6 key next 5 key next 4 key next 3 key next 2 key 1 next NULL int main(void) x { struct list *listptr, *new1, *new2; void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } p listptr = get_list( ); print_list( listptr ); void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); print_list( listptr ); } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> return 0; key } 222 next key next 6 key next 5 key next 4 key next 3 key next 2 key 1 next NULL int main(void) x { struct list *listptr, *new1, *new2; void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } p listptr = get_list( ); print_list( listptr ); void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); print_list( listptr ); } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> return 0; } key next 6 key next 5 key next 4 key next 3 key next 2 key next 222 key 1 next NULL int main(void) { struct list *listptr, *new1, *new2; void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } listptr = get_list( ); print_list( listptr ); void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); new2 print_list( listptr ); } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> new1 return 0; } listptr key next 6 key next 5 key next 4 key next 3 key next 2 key next 222 key 1 next NULL int main(void) { struct list *listptr, *new1, *new2; void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } listptr = get_list( ); print_list( listptr ); void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); new2 print_list( listptr ); } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> new1 return 0; } listptr key next 6 key next 5 key next 4 key next 3 key next 2 key next 222 key 1 next NULL int main(void) { struct list *listptr, *new1, *new2; void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } listptr = get_list( ); print_list( listptr ); void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); new2 print_list( listptr ); new1 return 0; 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> key } listptr } next key next 6 key next 5 key next 4 key next 3 key next 2 key next 222 key 1 next NULL int main(void) { struct list *listptr, *new1, *new2; void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } listptr = get_list( ); print_list( listptr ); void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); new2 print_list( listptr ); new1 return 0; key } listptr } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> 333 next key next 6 key next 5 key next 4 key next 3 key next 2 key next 222 key 1 next NULL int main(void) { struct list *listptr, *new1, *new2; listptr = get_list( ); print_list( listptr ); x void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } p void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); new2 print_list( listptr ); new1 return 0; key } listptr } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> 333 next key next 6 key next 5 key next 4 key next 3 key next 2 key next 222 key 1 next NULL int main(void) { struct list *listptr, *new1, *new2; listptr = get_list( ); print_list( listptr ); x void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } p void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); new2 print_list( listptr ); new1 return 0; key } listptr } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> 333 next key next 6 key next 5 key next 4 key next 3 key next 2 key next 222 key 1 next NULL int main(void) { struct list *listptr, *new1, *new2; listptr = get_list( ); print_list( listptr ); x void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } p void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); new2 print_list( listptr ); new1 return 0; key } listptr } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> 333 next key next 6 key next 5 key next 4 key next 3 key next 2 key next 222 key 1 next NULL int main(void) { struct list *listptr, *new1, *new2; listptr = get_list( ); print_list( listptr ); x void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } p void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); print_list( listptr ); return 0; } key } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> 333 next key next 6 key next 5 key next 4 key next 3 key next 2 key next 222 key 1 next NULL int main(void) { struct list *listptr, *new1, *new2; listptr = get_list( ); print_list( listptr ); x void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } p void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); print_list( listptr ); tmp } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> key return 0; key next } 333 next key next 6 key next 5 key next 4 key next 3 key next 2 key next 222 key 1 next NULL int main(void) { struct list *listptr, *new1, *new2; listptr = get_list( ); print_list( listptr ); x void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } p void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); print_list( listptr ); tmp key 333 return 0; next } tmp = *x; *x = *p; *p = tmp; p->next = x->next; } key 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> 333 next key next 6 key next 5 key next 4 key next 3 key next 2 key next 222 key 1 next NULL int main(void) { struct list *listptr, *new1, *new2; listptr = get_list( ); print_list( listptr ); x void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } p void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); print_list( listptr ); tmp key 333 return 0; next } tmp = *x; *x = *p; *p = tmp; p->next = x->next; } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> 5 key next key next 6 key next 5 key next 4 key next 3 key next 2 key next 222 key 1 next NULL int main(void) { struct list *listptr, *new1, *new2; listptr = get_list( ); print_list( listptr ); x void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } p void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); print_list( listptr ); tmp key 333 return 0; next } tmp = *x; *x = *p; *p = tmp; p->next = x->next; } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> 5 key next key next 6 key next 333 key next 4 key next 3 key next 2 key next 222 key 1 next NULL int main(void) { struct list *listptr, *new1, *new2; listptr = get_list( ); print_list( listptr ); x void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } p void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); print_list( listptr ); tmp key 333 return 0; next } tmp = *x; *x = *p; *p = tmp; p->next = x->next; } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> 5 key next key next 6 key next 333 key next 4 key next 3 key next 2 key next 222 key 1 next NULL int main(void) { struct list *listptr, *new1, *new2; listptr = get_list( ); print_list( listptr ); x void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } p void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); print_list( listptr ); tmp key 333 return 0; next } tmp = *x; *x = *p; *p = tmp; p->next = x->next; } 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> 5 key next key next 6 key next 333 key next 4 key next 3 key next 2 key next 222 key 1 next NULL int main(void) { struct list *listptr, *new1, *new2; void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } listptr = get_list( ); print_list( listptr ); void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); new2 print_list( listptr ); new1 return 0; 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> 5 key } listptr } next key next 6 key next 333 key next 4 key next 3 key next 2 key next 222 key 1 next NULL int main(void) { struct list *listptr, *new1, *new2; void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } listptr = get_list( ); print_list( listptr ); void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); new2 print_list( listptr ); new1 return 0; 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> 5 key } listptr } next key next 6 key next 333 key next 4 key next 3 key next 2 key next 222 key 1 next NULL int main(void) { struct list *listptr, *new1, *new2; void func1(struct list *x, struct list *p) { x->next = p->next->next; p->next->next = x; } listptr = get_list( ); print_list( listptr ); void func2(struct list *x, struct list *p) { struct list tmp; new1 = (struct list *)malloc(sizeof(struct list)); new1 -> key = 222; func1( new1, listptr->next->next->next); print_list( listptr ); tmp = *x; *x = *p; *p = tmp; p->next = x->next; new2 = (struct list *)malloc(sizeof(struct list)); new2 -> key = 333; func2( new2, listptr->next); new2 print_list( listptr ); new1 return 0; 画面出力 <6><5><4><3><2><1> <6><5><4><3><2><222><1> <6><333><4><3><2><222><1> 5 key } listptr } next key next 6 key next 333 key next 4 key next 3 key next 2 key next 222 key 1 next NULL
© Copyright 2025 ExpyDoc