题目:给出一个链表和一个数k,比如,链表为1→2→3→4→5→6,k=2,则翻转后2→1→6→5→4→3,若k=3,翻转后3→2→1→6→5→4,若k=4,翻转后4→3→2→1→6→5,用程序实现。
我的思路是:采用插入法翻转链表。
#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
int data;
struct node *next;
};
void CreateList(node *head,int length);
void PrintList(node *head);
void RotateList(node *head,