Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include "matrix.h"
- using namespace std;
- void main ()
- {
- matrix a;
- int i=0;
- cout << "zapolnenie matrix_1 ------------------------\n";
- a.create1();
- cout << "zapolnenie matrix_2 ------------------------\n";
- a.create2();
- while (true)
- {
- cout << "Chto vi hotite sdelat` ? \n 1)Izmenit` element v matrix_1 ? \n 2)Izmenit` element v matrix_2 ? \n 3)Umnozhit` ? \n 4) slozit` ? \n 5) Print ?";
- cin >> i;
- switch (i)
- {
- case 1:
- a.izmenit();
- break;
- case 2:
- a.izmenit2();
- break;
- case 3:
- a.umnozhit();
- break;
- case 4:
- a.summa();
- break;
- case 5:
- a.print_mas();
- break;
- }
- }
- }
- _______________________________________________________________________--
- #include "StdAfx.h"
- #include "matrix.h"
- #include <iostream>
- using namespace std;
- matrix::matrix(void)
- {
- }
- void matrix::create1()
- {
- int x=0,y=0,i=0;
- for (;x<=2;x++)
- {
- for (y=0;y<=2;y++)
- {
- cout << "Vvedite element mas[" << x <<"][" << y << "] = ?";
- cin >> i;
- m_matrix[x][y]=i;
- }
- }
- cout << "create Ok! \n";
- }
- void matrix::izmenit()
- {
- int x=0,y=0,i=0;
- cout << "Vvedite x y elementa kotoriy hotite izmenit` \n";
- cin >> x;
- cin >> y;
- if(x > 1 && y > 1)
- {
- cout << "Oshibka vvoda!\n";
- return;
- }
- cout << "Vvedite znachenie ";
- cin >> i;
- m_matrix[x][y]=i;
- cout << "matrix[" << x << "][" << y << "]=" << m_matrix[x][y] << "\n";
- return;
- }
- matrix::~matrix(void)
- {
- }
- void matrix::print_mas()
- {
- int x=0,y=0;
- cout << "matrix_1 \n";
- for (;x<=2;x++)
- {
- for (y=0;y<=2;y++)
- {
- cout << m_matrix[x][y] << " ";
- }
- cout << "\n";
- }
- cout << "matrix_2 \n";
- for (x=0;x<=2;x++)
- {
- for (y=0;y<=2;y++)
- {
- cout << m_matrix2[x][y] << " ";
- }
- cout << "\n";
- }
- }
- void matrix::summa()
- {
- int x=0,y=0,i=0;
- cout << "Summa------------------------\n";
- for (;x<=2;x++)
- {
- for (y=0;y<=2;y++)
- {
- cout << m_matrix[x][y] + m_matrix2[x][y] << " " ;
- }
- cout << "\n";
- }
- }
- void matrix::create2()
- {
- int x=0,y=0,i=0;
- for (;x<=2;x++)
- {
- for (y=0;y<=2;y++)
- {
- cout << "Vvedite element mas[" << x <<"][" << y << "] = ?";
- cin >> i;
- m_matrix2[x][y]=i;
- }
- }
- cout << "create Ok! \n";
- }
- void matrix::izmenit2()
- {
- int x=0,y=0,i=0;
- cout << "Vvedite x y elementa kotoriy hotite izmenit` \n";
- cin >> x;
- cin >> y;
- if(x > 1 && y > 1)
- {
- cout << "Oshibka vvoda!\n";
- return;
- }
- cout << "Vvedite znachenie ";
- cin >> i;
- m_matrix2[x][y]=i;
- cout << "matrix[" << x << "][" << y << "]=" << m_matrix2[x][y] << "\n";
- return;
- }
- void matrix::umnozhit()
- {
- int x=0,y=0,i=0,x1=0,y1=0,q1=0,q2=0,q3=0;
- cout << "Umnozhit------------------------\n";
- for(;x1<=2;x1++)
- {
- for (x=0;x<=2;x++)
- {
- for (y=0;y<=2;y++)
- {
- q1 += m_matrix[x1][y] * m_matrix2[y][x] ;
- }
- cout << q1 << " ";
- q1=0;
- }
- cout << "\n";
- }
- }
Add Comment
Please, Sign In to add comment