Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
list multiply
//Title of this code #include <iostream> using namespace std; struct node { int data; node* next; node(int d, node* n): data(d), next(n) {} }; /* 1 -> 7 -> 3 -> NULL - 378 9 -> 8 -> NULL - 89 */ node* multiply(node* head1, node* head2) { int carry = 0; node* res; node* num1 = head1; while (num1) { node* num2 = head2; while (num2) { int num = carry + (num1->data * num2->data); if (num > 9) { carry = num / 10; num = num % 10; } else carry = 0; cout << num << " "; //if (num){} num2 = num2->next; } num1 = num1->next; cout << endl; } return NULL; } int length(node* head) { int i = 0; while (head) { ++i; head = head->next; } return i; } int main() { node* num1 = new node(1, new node(2, new node(3, NULL))); node* num2 = new node(1, new node(1, NULL)); multiply(num2, num1); std::cout << "Hello, world!\n"; }
run
|
edit
|
history
|
help
0
template test
C++ MSVN Compiler Type Check
VC++ error LNK2001 with combined use of non-type template parameters
infix to postfix v 2.0
unresolved external symbol
std::current_exception makes a copy
VS'15 parameter pack sfinae
xyz1_1 programm
5sdgts
Multiple inheritance of empty classes - sizeof