Advertisement
Sanlover

Untitled

Dec 15th, 2020
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <Queue>
  3.  
  4. Queue get_product(Queue _First, Queue _Second)
  5. {
  6.     if (_First.size() != _Second.size())
  7.     {
  8.         std::cout << "Size must be equal" << std::endl;
  9.         return nullptr;
  10.     }
  11.     else
  12.     {
  13.         const int result_size = _First.size();
  14.         Queue result;
  15.  
  16.         for (int i = 0; i < result_size; i++)
  17.         {
  18.             int temp = _First.front() * _Second.front();
  19.             _First.pop();
  20.             _Second.pop();
  21.             Queue.push(temp);
  22.         }
  23.         return result;
  24.     }
  25.  
  26.  
  27. int main() {
  28.     Queue A,B;
  29.    
  30.     A.push(1);
  31.     A.push(2);
  32.     A.push(3);
  33.    
  34.     B.push(4);
  35.     B.push(5);
  36.     B.push(6);
  37.    
  38.     Queue C = get_product(A,B);
  39.    
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement