急!!求c语言单链表冒泡排序的详细流程图

急!!求c语言单链表冒泡排序的详细流程图尤其是交换的那几步。不要网上的非常感谢!

#include<stdio.h> #include<malloc.h> struct number { int num; struct number *next; }; void main() { struct number *head; struct number *p1,*p2,*p,*p3,*p4; int n=0,m,i,j; p1=p2=(struct number *)malloc(sizeof(struct number)); printf("\nWang jianfei 060806110006\n\n\n"); printf("Please enter the number: \n"); scanf("%d",&p1->num); head=NULL; while(p1->num!=NULL) { n=n+1; if(head==NULL) head=p1; else p2->next=p1; p2=p1; p1=(struct number *)malloc(sizeof(struct number)); scanf("%d",&p1->num); } p2->next=NULL; p=head; for(p4=head;p4!=NULL;p4=p4->next) { for(p3=head;p3->next!=NULL;p3=p3->next) { if(p4->num>p3->num) { m=p4->num; p4->num=p3->num; p3->num=m; } } p=head; } printf("\nNow,there %d numbers are: ",n); p=head; printf("\n"); if(head!=NULL) do { printf("%5d ",p->num); p=p->next; }while(p!=NULL); printf("\n"); getch(); }追问

是画图,不是代码

温馨提示:答案为网友推荐,仅供参考
第1个回答  2021-01-03

经典排序之冒泡排序

相似回答