Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// Alocarea dinamica a unei matrici de caractere.
- #include <iostream>
- using namespace std;
- char** alocaMatrice(int nrLin, int nrCol)
- {
- char **mat = new char*[nrLin];
- for(int i = 0;i < nrLin;i++)
- mat[i] = new char[nrCol];
- return mat;
- }
- void stergeMatrice(char** mat, int nrLin)
- {
- for(int i = 0;i < nrLin;i++)
- delete[] mat[i];
- delete[] mat;
- }
- int main()
- {
- // Exemplu de folosire a functiilor
- int n = 3, m = 4;
- char** v = alocaMatrice(n,m);
- for(int i = 0;i<n;i++)
- for(int j = 0;j<m;j++)
- v[i][j] = 'a' + i;
- for(int i = 0;i<n;i++, cout << '\n')
- for(int j =0;j<m;j++)
- cout << v[i][j] << ' ';
- stergeMatrice(v, n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement