From f1571e7b042704790b6b77a92b853448bec76d61 Mon Sep 17 00:00:00 2001 From: Shivam Singhal Date: Wed, 7 Jun 2017 21:41:54 +0530 Subject: [PATCH] Added sparse matrix program. --- Sparse matrix.cpp | 28 ++++++++++++++++++++++++++++ s[i] | 0 2 files changed, 28 insertions(+) create mode 100644 Sparse matrix.cpp create mode 100644 s[i] diff --git a/Sparse matrix.cpp b/Sparse matrix.cpp new file mode 100644 index 000000000..19452dfee --- /dev/null +++ b/Sparse matrix.cpp @@ -0,0 +1,28 @@ +/*A sparse matrix is a matrix which has number of zeroes greater than (m*n)/2, +where m and n are the dimensions of the matrix.*/ +#include +int main() +{ + int m,n,i,j,c=0; + cout << "Enter dimensions of matrix:"; + cin >> m >> n; + int a[m][n]; + cout << "Enter matrix elements:"; + for(i=0;> a[i][j]; + } + for(i=0;i((m*n)/2)) //Checking for sparse matrix + cout << "Sparse matrix"; + else + cout << "Not a sparse matrix"; +} diff --git a/s[i] b/s[i] new file mode 100644 index 000000000..e69de29bb