/* main.cpp */

#include "stdafx.h"
#include <iostream>
#include <Windows.h>
#include "Matrix.h"

using namespace std;

int main(){

	SetConsoleCP(1251);
	SetConsoleOutputCP(1251);

	Matrix Data;
	Data.Create();
	Data.OutPut();


	cout << endl;
    return 0;
}


/* Matrix.h */

#pragma once
#include "stdafx.h"
#include <iostream>
using namespace std;

class Matrix{
	private:
		int ** data;
		int employee, position;
	public:
		void Create();
		void Choice1(int ** data);
		void Choice0(int ** data);
		void OutPut();
};

/* Matrix.cpp */

#include "stdafx.h"
#include <iostream>
#include <iomanip>
using namespace std;
#include "Matrix.h"

void Matrix::Create(){
	cout << "Введите размер матрицы доходов NxM (N сотрудников x M должностей): " << endl;
	cin >> employee;
	cin >> position;
	int size = employee * position;
	data = new int*[size];
	for (int i = 0; i < size; i++){
		data[i] = new int[size];
	}
	int Choice;
	cout << "Сгенерировать матрицу (0) или вводить самостоятельно (...)?" << endl;
	cin >> Choice;
	Choice == 0 ? Choice0(data) : Choice1(data);

}

void Matrix::Choice1(int ** data) {
	for (int i = 0; i < employee; i++)
		for (int j = 0; j < position; j++) {
			cin >> data[i][j];
		}
}

void Matrix::Choice0(int ** data) {
	srand(time(0));
	for (int i = 0; i < employee; i++)
		for (int j = 0; j < position; j++) {
			data[i][j] = rand() % 100;
		}
}

void Matrix::OutPut() {
	cout << endl  << "Матрица доходов:" << endl << endl;
	for (int i = 0; i < employee; i++) {
		for (int j = 0; j < position; j++) {
			cout << setw(2) << data[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;
}

