online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> 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) { node* n = new node(data); head = n; return; } else { node* temp = head; node* n = new node(data); while(temp->next != NULL) { temp = temp->next; } temp->next = n; return; } } void build(node* &head,int n) { int count = 0; int data; while(count!=n) { cin>>data; insertattail(head,data); count++; } } void print(node* head) { while(head != NULL) { cout<<head->data<<" "; head = head->next; } } node* merge(node* a,node* b) { if(a==NULL) { return b; } if(b==NULL) { return a; } node* c; if(a->data < b->data) { c = a; c->next = merge(a->next,b); } else { c = b; c->next = merge(a,b->next); } return c; } int main() { int test; cin>>test; while(test!=0) { int n1; cin>>n1; node* head1 = NULL; build(head1,n1); int n2; cin>>n2; node* head2 = NULL; build(head2,n2); node* s = merge(head1,head2); print(s); test--; } return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue