Re: [algogeeks] Add Two Numbers stored in Linked Lists

2011-07-22 Thread Rajeev Kumar
Please check this program in java and add your comments if you feel anything wrong http://rajeevprasanna.blogspot.com/2011/07/add-two-numbers-stored-in-linked-lists.html 2011/7/18 η!Ƭ!گђ nitish.ii...@gmail.com #include stdio.h #include stdlib.h #include malloc.h struct node { char ch;

[algogeeks] Add Two Numbers stored in Linked Lists

2011-07-18 Thread Navneet Gupta
Write a recursive routine to add two numbers stored in Linked List in O(n) time and return result in List 3 Lists are not to be reversed. Example: List 1 : 1 2 3 4 5 (Num1 - 12345) List 2 : 6 7 8 (Num2 - 678) List 3 (output) - 1 3 0 2 3 (12345 + 678) -- Regards, Navneet -- You

Re: [algogeeks] Add Two Numbers stored in Linked Lists

2011-07-18 Thread SkRiPt KiDdIe
#includecstdlib #includeiostream using namespace std; struct node{ int val; node *next; }; node * Input(int n) { node *temp,*list,*end; int x; for(int i=0;in;i++) { cinx; temp=(node*)malloc(sizeof(node));temp-val=x;temp-next=NULL;

Re: [algogeeks] Add Two Numbers stored in Linked Lists

2011-07-18 Thread η!Ƭ!گђ
#include stdio.h #include stdlib.h #include malloc.h struct node { char ch; struct node *ptr; }*tp,*sp; int c = 0; int insert(struct node *list) { int n,num,hd; scanf(%d,n); hd = n; struct node *temp; n--; while(n--) { scanf(%d,num); list-ch = num; temp = (struct node