MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / sparseMatrix

Function sparseMatrix

Matrix/sparseMatrix.c:6–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4int nonZero;
5
6void sparseMatrix(int arr[100][100],int rows,int columns){
7
8 int crr[rows][nonZero],p=0,q=0;
9
10 for(int i=0;i<rows;i++){
11 for(int j=0;j<columns;j++){
12
13 if (arr[i][j]>0){
14 crr[p][q]=i;
15 crr[p+1][q]=j;
16 crr[p+2][q]=arr[i][j];
17 q++;
18
19 }
20 }
21 }
22
23 for(int f=0; f<rows;f++){
24 for(int g=0;g<nonZero;g++){
25 printf("%d ", crr[f][g]);
26 }
27 printf("\n");
28 }
29
30}
31
32int main()
33{

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected