Advertisement
informaticage

MatrixForPhysics

Sep 17th, 2017
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. double** generateMatrix(const int dimensions) {
  7.     double** matrix;
  8.     matrix = new double*[dimensions];
  9.  
  10.     for (int height = 0; height < dimensions; height++) {
  11.         matrix[height] = new double[dimensions];
  12.         for (int width = 0; width < dimensions; width++) {
  13.             cout << "inserisci riga " << height + 1 << " colonna " << width + 1 << endl;
  14.             cin >> matrix[height][width];
  15.         }
  16.     }
  17.     return matrix;
  18. }
  19.  
  20. void getFirstElement (double **matrice) {
  21.     cout << matrice[0][0];
  22. }
  23.  
  24. int main(void) {
  25.     int dim;
  26.     cout << "Inserire dimensione matrice: ";
  27.     cin >> dim;
  28.     getFirstElement(generateMatrix(dim));
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement