SHARE
TWEET

lab

a guest May 19th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. const int n = 5;
  3. const int m = 5;
  4.  
  5. using namespace std;
  6. int func_arr(int tmp[], int size);
  7. int main()
  8. {
  9.     const int size = 10;
  10.     const int n = 10; const int m = 10;// размер масcива
  11.     int arr[size];
  12.     int tmp[size];
  13.     int mat[n][m];
  14.     for (int i = 0; i < n; i++) {
  15.         for (int j = 0; j < m; j++) {
  16.             mat[i][j] = i - j;
  17.         }
  18.     }
  19.     for (int i = 0; i < n; i++) {
  20.         for (int j = 0; j < m; j++) {
  21.             cout << mat[i][j] << "\t";
  22.         }
  23.         cout << endl;
  24.     }
  25.     cout << "New array" << endl;
  26.     for (int j = 0; j < m; j++)
  27.     {
  28.         for (int i = 0; i < n; i++) {
  29.             tmp[i] =mat[i][j];
  30.         }
  31.         arr[j] = func_arr(tmp, size);
  32.         cout << arr[j] << "\t";
  33.     }
  34.     return 0;
  35.  
  36. }
  37. int func_arr(int tmp[], int size)
  38. {   int count=0;
  39.     for (int i = 0; i < size; i++)
  40.         if (tmp[i] > 0) {
  41.             count = count + 1;
  42.         }
  43.     return count;
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top