Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. #define CLS system("cls")
  5. class Matrix {
  6. private:
  7. public:
  8. int rows, collons;
  9. int** data;
  10. void create() {
  11. data = new int*[rows];
  12. for (int i = 0; i < rows; i++)
  13. {
  14. data[i] = new int[collons];
  15. }
  16. }
  17. Matrix(int r, int c) :rows(r), collons(c) { create(); }
  18. void ShowMatrix() {
  19.  
  20. for (int i = 0; i < rows; i++) {
  21. cout << "|" ;
  22. for (int j = 0; j < collons; j++) {
  23. cout.width(4);
  24. cout << data[i][j];;
  25. }
  26. cout<< "|" << endl;
  27. }
  28. }
  29. void fillMatrix() {
  30. for (int i = 0; i < rows; i++) {
  31.  
  32. for (int j = 0; j < collons; j++)
  33. data[i][j] = rand() % 11;
  34. }
  35.  
  36. }
  37. };
  38. int main() {
  39. Matrix SuperMatrix(3, 3);
  40. SuperMatrix.fillMatrix();
  41. SuperMatrix.ShowMatrix();
  42. system("pause");
  43. //spasibo isusu
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement