Advertisement
gasaichan

Untitled

Mar 26th, 2017
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <clocale>
  4. #include <cstdlib>
  5.  
  6. #define ROWS 4
  7. #define COLS 3
  8.  
  9. using namespace std;
  10.  
  11. void main() {
  12.     setlocale(LC_ALL, "Russian");
  13.     int B[ROWS][COLS], A[ROWS] = { 0, 0, 0, 0 };
  14.  
  15.     printf("\nArray B: \n");
  16.     for (int i = 0; i < ROWS; i++) {
  17.         for (int j = 0; j < COLS; j++) {
  18.             B[i][j] = rand() % 100 - 50;
  19.             printf("%d\t", B[i][j]);
  20.             if (B[i][j] > 0) {
  21.                 A[i] += B[i][j];
  22.             }
  23.         }
  24.         printf("\n");
  25.  
  26.     }
  27.  
  28.     printf("\nArray A\n");
  29.     for (int i = 0; i < ROWS; i++) {
  30.         printf("%d\t", A[i]);
  31.     }
  32.  
  33.     _getch();
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement