Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class float_num;
- class Matrix {
- float** m;
- int n;
- public:
- Matrix();
- ~Matrix();
- void print();
- void input();
- friend void multiple(Matrix* M, float_num F);
- };
- Matrix::Matrix() {
- cout << "Введите n\n";
- cin >> n;
- int i;
- m = new float* [n];
- for (i = 0; i < n; i++) {
- m[i] = new float[n];
- }
- }
- Matrix::~Matrix() {
- int i;
- for (i = 0; i < n; i++) {
- delete[] m[i];
- }
- delete[] m;
- }
- void Matrix::input() {
- int i, j;
- for (i = 0; i < n; i++) {
- for (j = 0; j < n; j++) {
- cin >> m[i][j];
- }
- }
- }
- void Matrix::print() {
- int i, j;
- for (i = 0; i < n; i++) {
- for (j = 0; j < n; j++) {
- cout << m[i][j] << " ";
- }
- cout << endl;
- }
- }
- class float_num {
- float num;
- public:
- float_num() {
- cout << "Введите число\n";
- cin >> num;
- }
- friend void multiple(Matrix* M, float_num F);
- };
- void multiple(Matrix *M, float_num F) {
- int i, j;
- for (i = 0; i < M->n; i++) {
- for (j = 0; j < M->n; j++) {
- M->m[i][j] *= F.num;
- }
- cout << endl;
- }
- }
- int main()
- {
- Matrix M;
- M.input();
- float_num F;
- multiple(&M, F);
- M.print();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement