Advertisement
nikitakrut58

4DzNum8

Nov 26th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. using namespace std;
  5.  
  6.  
  7. int main()
  8. {
  9.     int strok1, strok2, stolb1, stolb2;
  10.     double** a, ** b, ** c;
  11.     cout << "strok matrizi 1:";
  12.     cin >> strok1;
  13.     cout << "kol stoblzov 1:";
  14.     cin >> stolb1;
  15.     cout << "strok matrizi 2:";
  16.     cin >> strok2;
  17.     cout << "kol stoblzov 2:";
  18.     cin >> stolb2;
  19.     if (stolb1 != strok2)
  20.     {
  21.         cout << "error";
  22.        
  23.     }
  24.    
  25.     a = new double* [strok1];
  26.     cout << "vvedite element 1 matrizi" << endl;
  27.     for (int i = 0; i < strok1; i++)
  28.     {
  29.         a[i] = new double[stolb1];
  30.         for (int j = 0; j < stolb1; j++)
  31.         {
  32.             cout << "a[" << i << "][" << j << "]= ";
  33.             cin >> a[i][j];
  34.         }
  35.     }
  36.    
  37.    
  38.     b = new double* [strok2];
  39.     cout << "vvedite element 2 matrizi" << endl;
  40.     for (int i = 0; i < strok2; i++)
  41.     {
  42.         b[i] = new double[stolb2];
  43.         for (int j = 0; j < stolb2; j++)
  44.         {
  45.             cout << "b[" << i << "][" << j << "]= ";
  46.             cin >> b[i][j];
  47.         }
  48.     }
  49.    
  50.    
  51.     c = new double* [strok1];
  52.     for (int i = 0; i < strok1; i++)
  53.     {
  54.         c[i] = new double[stolb2];
  55.         for (int j = 0; j < stolb2; j++)
  56.         {
  57.             c[i][j] = 0;
  58.             for (int k = 0; k < stolb1; k++)
  59.                 c[i][j] += a[i][k] * b[k][j];
  60.         }
  61.     }
  62.    
  63.    
  64.     cout << "Matriza C=" << endl;
  65.     for (int i = 0; i < strok1; i++)
  66.     {
  67.         for (int j = 0; j < stolb2; j++)
  68.             cout << c[i][j] << " ";
  69.         cout << endl;
  70.     }
  71.    
  72.     double moneyBol=c[0][0];
  73.     double moneyMen=c[0][0];
  74.     int chet1=0;
  75.     int chet2=0;
  76.    
  77.     for (int i = 0; i < 3; i++)
  78.     {
  79.         if(c[i][0]>=moneyBol){
  80.             chet1=i;
  81.         }
  82.     }
  83.    
  84.     for (int i = 0; i < 3; i++)
  85.     {
  86.         if(c[i][0]<=moneyMen){
  87.             chet2=i;
  88.         }
  89.     }
  90.     cout<<"Bolshe deneg:"<<chet1+1<<endl;
  91.     cout<<"Menshe deneg:"<<chet2+1<<endl;
  92.    
  93.     double comisionBolshe=c[0][1];
  94.     double comisionMenshe=c[0][1];
  95.     int chet3=0;
  96.     int chet4=0;
  97.    
  98.     for (int i = 0; i < 3; i++)
  99.     {
  100.         if(c[i][1]>=comisionBolshe){
  101.             chet3=i;
  102.         }
  103.     }
  104.    
  105.     for (int i = 0; i < 3; i++)
  106.     {
  107.         if(c[i][1]<=comisionMenshe){
  108.             chet4=i;
  109.         }
  110.     }
  111.     cout<<"Bolshe comision:"<<chet3+1<<endl;
  112.     cout<<"Menshe comision:"<<chet4+1<<endl;
  113.  
  114.     double summaDeng=0;
  115.     double summaKomis=0;
  116.     for (int i = 0; i < 3; i++)
  117.     {
  118.         summaDeng=summaDeng+c[i][0];
  119.     }
  120.      cout<<"Summa Deneg:"<<summaDeng<<endl;
  121.    
  122.     for (int i = 0; i < 3; i++)
  123.     {
  124.         summaKomis=summaKomis+c[i][1];
  125.         }
  126.     cout<<"Summa Komis:"<<summaKomis<<endl;
  127.    
  128.     double SumItog=0;
  129.    
  130.     SumItog=summaKomis+summaDeng;
  131.     cout<<"Summa Vsego:"<<SumItog<<endl;
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement