#include
using namespace std;
class node{
public:
int data;
node* next;
node(int d){
data=d;
next=NULL;
}
};
void insertattail(node*&head,int data){
if(head==NULL){
head=new node(data);
return;
}
nodetail=head;
while(tail->next!=NULL){
tail=tail->next;
}
tail->next= new node(data);
return ;
}
void buildlist(node&head,int n){
int data;
int count=0;
while(count<n){
cin>>data;
insertattail(head,data);
count++;
} return;
}
void printlist(nodehead){
while(head!=NULL){
cout<data<<" ";
head=head->next;
}
cout<<endl;
}
int length(nodehead){
int len=0;
while(head!=NULL){
head=head->next;
len+=1;
}
return len;
}
node* append(nodehead,int n,int k){
nodec=head;
node*p=head;
int count=0;
while(count<n-k){
p=p->next;
c=c->next;
}
// int m=length©;
nodetemp=c;
while(temp->next!=NULL){
temp=temp->next;
}
temp->next=head;
head=p->next;
p->next=NULL;
return head;
}
int main() {
int n;
cin>>n;
nodehead=NULL;
buildlist(head,n);
// printlist(head);
int k;
cin>>k;
head=append(head,n,k);
printlist(head);
}
whats wrong in this code?