Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Not Common Numbers
#include<iostream> #include<conio.h> using namespace std; struct Record { int n; Record* p; Record() { cin >> n; p = NULL; } }; Record* inputVector(Record* temp) { temp = new Record(); if(temp->n != 0) temp->p = inputVector(temp->p); return temp; } bool search(Record* temp, int c) { if(temp->n == c) return true; else if(temp->p != NULL) return search(temp->p, c); else return false; } void outputNotCommon(Record* pointer1, Record* pointer2) { if(!search(pointer2, pointer1->n)) cout << pointer1->n << ' '; if(pointer1->p != NULL) outputNotCommon(pointer1->p, pointer2); } void outputVector(Record* pointer) { cout << pointer->n << ' '; if(pointer->p != NULL) outputVector(pointer->p); } void main() { Record* pointer1 = inputVector(NULL); cout << endl; Record* pointer2 = inputVector(NULL); cout << endl << endl; outputNotCommon(pointer1, pointer2); getch(); }
run
|
edit
|
history
|
help
0
Buggy Strcat
#30.2
Computing factorial of an integer with recursion and iteration
throwing Copyable versus throwing MoveOnly
derived_tempalte
Shadow pointer member variable
VC++ error C2440 with combined use of non-type template parameters
Waiting for Multiple Objects
#7
#30.3