Advertisement
Spocoman

05. Cartesian Product

Oct 27th, 2023 (edited)
701
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int length;
  7.     cin >> length;
  8.    
  9.     int *arr = new int[length];
  10.  
  11.     for (int i = 0; i < length; i++) {
  12.         cin >> arr[i];
  13.     }
  14.  
  15.     for (int i = 0; i < length; i++) {
  16.         for (int j = 0; j < length; j++)
  17.         {
  18.             cout << arr[i] * arr[j] << ' ';
  19.         }
  20.     }
  21.     cout << endl;
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement