Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- int main()
- {
- int strok1, strok2, stolb1, stolb2;
- double** a, ** b, ** c;
- cout << "strok matrizi 1:";
- cin >> strok1;
- cout << "kol stoblzov 1:";
- cin >> stolb1;
- cout << "strok matrizi 2:";
- cin >> strok2;
- cout << "kol stoblzov 2:";
- cin >> stolb2;
- if (stolb1 != strok2)
- {
- cout << "error";
- }
- a = new double* [strok1];
- cout << "vvedite element 1 matrizi" << endl;
- for (int i = 0; i < strok1; i++)
- {
- a[i] = new double[stolb1];
- for (int j = 0; j < stolb1; j++)
- {
- cout << "a[" << i << "][" << j << "]= ";
- cin >> a[i][j];
- }
- }
- b = new double* [strok2];
- cout << "vvedite element 2 matrizi" << endl;
- for (int i = 0; i < strok2; i++)
- {
- b[i] = new double[stolb2];
- for (int j = 0; j < stolb2; j++)
- {
- cout << "b[" << i << "][" << j << "]= ";
- cin >> b[i][j];
- }
- }
- c = new double* [strok1];
- for (int i = 0; i < strok1; i++)
- {
- c[i] = new double[stolb2];
- for (int j = 0; j < stolb2; j++)
- {
- c[i][j] = 0;
- for (int k = 0; k < stolb1; k++)
- c[i][j] += a[i][k] * b[k][j];
- }
- }
- cout << "Matriza C=" << endl;
- for (int i = 0; i < strok1; i++)
- {
- for (int j = 0; j < stolb2; j++)
- cout << c[i][j] << " ";
- cout << endl;
- }
- double moneyBol=c[0][0];
- double moneyMen=c[0][0];
- int chet1=0;
- int chet2=0;
- for (int i = 0; i < 3; i++)
- {
- if(c[i][0]>=moneyBol){
- chet1=i;
- }
- }
- for (int i = 0; i < 3; i++)
- {
- if(c[i][0]<=moneyMen){
- chet2=i;
- }
- }
- cout<<"Bolshe deneg:"<<chet1+1<<endl;
- cout<<"Menshe deneg:"<<chet2+1<<endl;
- double comisionBolshe=c[0][1];
- double comisionMenshe=c[0][1];
- int chet3=0;
- int chet4=0;
- for (int i = 0; i < 3; i++)
- {
- if(c[i][1]>=comisionBolshe){
- chet3=i;
- }
- }
- for (int i = 0; i < 3; i++)
- {
- if(c[i][1]<=comisionMenshe){
- chet4=i;
- }
- }
- cout<<"Bolshe comision:"<<chet3+1<<endl;
- cout<<"Menshe comision:"<<chet4+1<<endl;
- double summaDeng=0;
- double summaKomis=0;
- for (int i = 0; i < 3; i++)
- {
- summaDeng=summaDeng+c[i][0];
- }
- cout<<"Summa Deneg:"<<summaDeng<<endl;
- for (int i = 0; i < 3; i++)
- {
- summaKomis=summaKomis+c[i][1];
- }
- cout<<"Summa Komis:"<<summaKomis<<endl;
- double SumItog=0;
- SumItog=summaKomis+summaDeng;
- cout<<"Summa Vsego:"<<SumItog<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement