Advertisement
Guest User

Untitled

a guest
May 17th, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cstdlib>
  4.  
  5. using namespace std;
  6.  
  7. int init_array_c (const int *arr_a, size_t a_size, const int *arr_b, size_t b_size)
  8. {
  9.     int C[b_size][a_size];
  10.     bool first = true;
  11.     int max;
  12.    
  13.     for (size_t j = 0; j < b_size; j++)
  14.     {
  15.         for (size_t i = 0; i < a_size; i++)
  16.         {
  17.             C[j][i] = arr_b[j] * arr_a[i];
  18.            
  19.             if(first == true)
  20.             {
  21.                 max = C[j][i];
  22.                 first = false;
  23.             }
  24.             if (max < C[j][i])
  25.                 max = C[j][i];
  26.            
  27.             cout << setw(4) << C[j][i];
  28.         }
  29.         cout << endl;
  30.     }
  31.     return max;
  32. }
  33.  
  34. int main (void)
  35. {
  36.     const size_t a_size = 5, b_size = 10;
  37.     size_t j, i;
  38.     int A[a_size] = {1, 2, 5, 4, 12};
  39.     int B[b_size] = {7, 6, 8, 23, 9, 10, 11, 3, 13, 14};
  40.    
  41.     cout << "array A: \n";
  42.     for (i = 0; i < a_size; i++)
  43.         cout << setw(4) << A[i];
  44.    
  45.     cout << "\n\narray B: \n";
  46.     for (i = 0; i < b_size; i++)
  47.         cout << setw(4) << B[i];
  48.    
  49.     cout << "\n\n";
  50.     cout << "\nmax: " << init_array_c(A, a_size, B, b_size) << endl;
  51.     cout << endl;
  52.     system("pause");
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement