SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <iostream>
  3. #include <cstdlib>
  4. #include <ctime>
  5.  
  6. #define N 64
  7. #define M 8
  8.  
  9. using namespace std;
  10.  
  11. int main(int argc, char **argv)
  12. {
  13.     // Объявление переменных
  14.     float S1 = 1, S2 = 2;
  15.     float **A = new float* [N], **B = new float* [N], **C = new float* [N], **Y = new float* [N];
  16.    
  17.     for (int i = 0; i < N; i++) {
  18.         A[i] = new float [M];
  19.         B[i] = new float [M];
  20.         C[i] = new float [M];
  21.         Y[i] = new float [M];
  22.     }
  23.     // Инициализация массивов
  24.     srand(1);
  25.     for (int i = 0; i < N; i++)
  26.         for (int j = 0; j < M; j++) {
  27.             A[i][j] = float(1 + rand() % 10);
  28.             B[i][j] = float(10 + rand() % 100);
  29.             C[i][j] = float(100 + rand() % 1000);
  30.         }
  31.    
  32.     // Вычисление формулы
  33.     for (int i = 0; i < N; i++)
  34.         for (int j = 0; j < M; j++) {
  35.             Y[i][j] = (A[i][j] + S1 * B[i][j]) * C[i][j] + S2;
  36.         }
  37.    
  38.     // Вывод результатов и времени вычисления
  39.     cout << endl <<"Array Y[" << N << "][" << M << "]: " << endl;
  40.     for (int i = 0; i < N; i++)
  41.         for (int j = 0; j < M; j++) {
  42.             cout << Y[i][j] << " ";
  43.         }
  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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top