Advertisement
KShah

Untitled

Nov 11th, 2021
664
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <cstdlib>
  2. #include <fstream>
  3. #include <iostream>
  4. #include <cstring>
  5.  
  6. int main(int argc, char** argv) {
  7.  
  8.     int* sizeArr = new int[argc - 1];
  9.     for (int i = 1; i < argc; ++i) {
  10.         sizeArr[i - 1] = std::atoi(argv[i]);
  11.     }
  12.  
  13.    
  14.     long long size = 1, sum = 0;
  15.     int** arr = new int*[argc - 1];
  16.    
  17.     for (int i = 0; i < argc - 1; ++i) {
  18.         arr[i] = new int[sizeArr[i]];
  19.  
  20.         sum = 0;
  21.         for (int j = 0; j < sizeArr[i]; ++j) {
  22.             std::cin >> arr[i][j];
  23.             sum += arr[i][j];
  24.         }
  25.         size *= sum;
  26.     }
  27.  
  28.     std::cout << size << "\n";
  29.    
  30.     delete[] sizeArr;
  31.     for (int i = 0; i < argc - 1; ++i) {
  32.         delete[] arr[i];
  33.     }
  34.  
  35.     delete[] arr;
  36.    
  37.     return 0;
  38. }
  39.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement