SHARE
TWEET

Lab5A

a guest Nov 19th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<locale.h>
  3. #include <iomanip>
  4. #include <ctime>
  5. using namespace std;
  6. int main()
  7. {
  8.     setlocale(LC_ALL, "");
  9.     int i, j,m=0,n=0,k=0;
  10.     cout << "Enter number of strings:";
  11.     cin >> n;
  12.     cout << "Enter number of colums:";
  13.     cin >> m;
  14.     double **a=new  double *[n];
  15.     for (i = 0; i < n; i++)
  16.         a[i] = new double[m];
  17.  
  18.     for (i = 0; i < n; i++)
  19.     {
  20.         for (j = 0; j < m; j++)
  21.         {
  22.             a[i][j] = rand() % 21 -10;
  23.         }
  24.     }
  25.      
  26.        
  27.     for (i = 0; i < n; i++)
  28.     {
  29.         for (j = 0; j < m; j++)
  30.         {
  31.             cout <<setw(3)<< a[i][j] <<  '\t';
  32.            
  33.         }
  34.         cout << endl;
  35.     }
  36.     for (i = 0; i < n; i++)
  37.     {
  38.         k = 0;
  39.         for (j = 0; j < m; j++)
  40.         {
  41.             if (a[i][j] > 0)
  42.                 k++;
  43.         }
  44.        
  45.         cout << "Число положительных элементов в " << i + 1 << " " << "строке: " << k << endl;
  46.  
  47.     }
  48.             for (i = 0; i < n; i++)
  49.                 delete[] a[i];
  50.             delete[] a;
  51.    
  52. }
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