mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
sparse matrix docs
This commit is contained in:
parent
0994e6e028
commit
bc8fda9056
@ -1,10 +1,11 @@
|
|||||||
/** @file
|
/** @file
|
||||||
* A sparse matrix is a matrix which has number of zeroes greater than
|
* A sparse matrix is a matrix which has number of zeroes greater than
|
||||||
* \f$\frac{m*n}{2}\f$, where m and n are the dimensions of the matrix.
|
* \f$\frac{m\times n}{2}\f$, where m and n are the dimensions of the matrix.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
/** main function */
|
||||||
int main() {
|
int main() {
|
||||||
int m, n;
|
int m, n;
|
||||||
int counterZeros = 0;
|
int counterZeros = 0;
|
||||||
@ -30,7 +31,8 @@ int main() {
|
|||||||
// counts the zero's
|
// counts the zero's
|
||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
if (a[i][j] == 0) counterZeros++; // Counting number of zeroes
|
if (a[i][j] == 0)
|
||||||
|
counterZeros++; // Counting number of zeroes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user