fixed dynamic array

This commit is contained in:
Krishna Vedala 2020-05-26 09:37:36 -04:00
parent 899be6a1f1
commit dd20bf9442
No known key found for this signature in database
GPG Key ID: BA19ACF8FC8792F7

View File

@ -13,7 +13,9 @@ int main() {
std::cin >> m;
std::cin >> n;
int a[m][n];
int **a = new int *[m];
for (int i = 0; i < m; i++) a[i] = new int[n];
std::cout << "Enter matrix elements:";
std::cout << "\n";
@ -37,4 +39,8 @@ int main() {
std::cout << "Sparse matrix";
else
std::cout << "Not a sparse matrix";
for (int i = 0; i < m; i++) delete[] a[i];
delete[] a;
return 0;
}