Daniel_leinaD

4.2

Apr 11th, 2022 (edited)
640
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 <clocale>
  3. #include <math.h>
  4. #include <iomanip>
  5. using namespace std;
  6.  
  7. const int n = 6, m = 7;
  8.  
  9. int f(int x[n][m]){
  10.   int pol = 0, otr = 0;
  11.   for (int i = n/2; i < n; i++){
  12.     for (int j = 0; j < m; j++){
  13.       if (x[i][j] < 0){
  14.         otr++;
  15.       }
  16.       if (x[i][j] > 0){
  17.         pol++;
  18.       }
  19.     }
  20.   }
  21.   cout << '\n' << "Кол-во отрицательных = " << otr;
  22.   cout << '\n' << "Кол-во положительных = " << pol;
  23.   cout << '\n';
  24.   return 0;
  25. }
  26.  
  27.  
  28. int main(){
  29.   int a[n][m];
  30.   for (int i = 0; i < n; i++){
  31.     cout << '\n';
  32.     for (int j = 0; j < m; j++){
  33.       a[i][j] = rand()%100 - 50;
  34.       cout << setw(4) << a[i][j];
  35.     }
  36.   }
  37.  
  38.   cout << '\n' <<  f(a);
  39. }
Add Comment
Please, Sign In to add comment