Sparse matrix - 3 tuple representation

 //program to 3-tuple representation  
 #include<stdio.h>  
 #include<unistd.h>  
 #define SIZE 3000;  
 void main()  
 {  
  int a[5][5],row,columns,i,j;  
  printf("Enter the order of the matrix(5*5)");  
  scanf("%d %d",&row,&columns);  
  printf("Enter the element of the matrix\n");  
  for(i=0;i<row;i++)  
   for(j=0;j<columns;j++)  
    {  
      scanf("%d", &a[i][j]);  
    }  
  printf("3-tuple representation");  
  for(i=0;i<row;i++)  
   for(j=0;j<columns;j++)  
    {  
      if(a[i][j]!=0)  
       {  
        printf("%d %d %d", (i+1),(j+1),a[i][j]);  
       }  
    }  
  getchar();  
 }  

Comments

Popular posts from this blog

Setting up atalanta ATPG to work on Linux

Generating 16k ROM using Xilinx IP COREGEN and simulating it in modelsim