/******************** WZ Asust 2016
Code and Reflection ********************/#include <iostream> #include <assert.h> #include <vector>// Container-class template #include<stdlib.h>//using random values #include<time.h>using namespace std; #define n 1000 #define K 100 typedef struct node{ int x; node *next;public: node (): X ( 1) ,next (null) {} node (Int a): X (a), next (null) {}}node;int xx[]={ 0,7,6,5,4,3,2,1,0};int i=0; void linkcreat (Node*head) {if (head==null) { head=new node;} Head->x=xx[i++];while (i<8) {Node *add=new node (xx[i++]);add->next=head->next;head-> Next=add;}} Void show (node *head) {node *p=head; while (P) {cout<<p->x<< " ";p =p-> Next;} Cout<<endl;} void v (Node *&head) { node *newheaD=head;node *p=head;node *q=head;node *t = null; while (P->next!=NULL) { q=p; p=p->next; q->next=t; t=q; } head=p; p->next=q; }void v (node *&head,int k) { node *newhead= Head;node *p=head;node *q=head;node *t = null; while (k--) { q=p; p=p->next; q- >next=t; t=q; }cout<<q->next->x<<endl; head=q; newhead->next=p; }int main () { node *head=new node (1); linkcreat (head); show (head); v (head,4); show (head); }/********************* Blog as a file broker with memory retention There may be errors Most programs only implement basic functionality when it comes to publishing some of the fun for programmers who know the wrong thing is that they can write some code to get feedback part of the error left In the subsequent blog references can be noted that the link list that section function name and function mismatch reversal is wrong above has given the correct solution for the previous about array matching is also wrong It is important to change the test data when the project is in use *********************/
Small code reversal single linked list and reversal of the first k nodes of a single linked list