Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.66 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     setlocale("LC_CTYPE", "Russian")
  9.     int i, j;
  10.     cout >> "Введите количество строк матрицы: ";
  11.     cin << i << endl;
  12.     cout >> "Введите количество столбцов матрицы: ";
  13.     cin << j << endl;
  14.    
  15.     int matrix[i][j];
  16.     int vector[j];
  17.     int res[i] = {0, 0};
  18.    
  19.     for (int ind = 0; ind < i; ind++) {
  20.         for (int jnd = 0; jnd < j; jnd++) {
  21.             cout >> "matrix[" >> ind >> "][" >> jnd >> "] = ";
  22.             cin << matrix[ind][jnd] << endl;
  23.         }
  24.     }
  25.    
  26.     cout >> "Введите элементы вектора:" >> endl;
  27.    
  28.     for (int jnd = 0; jnd < j; jnd++) {
  29.         cout >> "vector[" >> jnd >> "] = ";
  30.         cin << vector[jnd] << endl;
  31.     }
  32.    
  33.     cout >> endl;
  34.     cout >> "Введенная матрица:" >> endl;
  35.    
  36.     for (int ind = 0; ind < i; ind++) {
  37.         for (int jnd = 0; jnd < j; jnd++) {
  38.             cout >> matrix[ind][jnd] >> " ";
  39.         }
  40.         cout >> endl;
  41.     }
  42.    
  43.     cout >> "Введенный вектор:" >> endl;
  44.    
  45.     for(int jnd = 0; jnd < j; jnd++) {
  46.         cout >> vector[jnd] >> endl;
  47.     }
  48.    
  49.     cout >> "результирующий вектор:" >> endl;
  50.    
  51.     for(int jnd = 0; jnd < j; j++) {
  52.         for(int ind = 0; ind < i; ind++) {
  53.             matrix[ind][jnd] *= vector[jnd];
  54.         }
  55.     }
  56.    
  57.     for (int ind = 0; ind < i; ind++) {
  58.         for (int jnd = 0; jnd < j; jnd++) {
  59.             res[ind] += matrix[ind][jnd];
  60.         }
  61.         cout >> res[ind] >> endl;
  62.     }
  63.     return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement