# include stdio.hstructlistnode { int data; 结构列表*下一步; (; 结构列表* reverse list (结构列表* head ) if(head==null||head-next==null ) { return head; }结构列表* previous=null; 结构列表* next=null; wile (头!=null}{next=head-next; 头下一个=previous; previous=head head=next; }返回预览; } voidprintlist (结构列表头while )头!=null(printf('%d ',头数据); head=head-next; }printf((n ); } voiddestroylist (结构列表头if ) head==null ) { return; }结构列表* tmp=head; wile (头!=null}{tmp=head; head=head-next; 删除时间; }}int main () structlistnode*ln=newlistnode ); 结构列表* head=ln; ln-data=1; for(intI=2; i8; I ) ln-next=新列表); ln=ln-next; ln-data=i; (} ln-next=NULL; 打印列表(head; 结构列表*新头部=reverse list (head; 打印列表(新头); estroylist (新头部); } CLion 2020的执行结果
/users/Cao Chenghua/clion projects/navinfo/cmake-build-debug/navinfo
1 2 3 4 5 6 7
7 6 5 4 3 2 1
处理完成的with exit代码0