Advertisement
Shishu

declare and take input in an n*n matrix and build an adjacen

Oct 26th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<time.h>
  3. #define n 4
  4. int main()
  5. {
  6.  
  7.     int a,i,j,mat[100][100];
  8.  
  9.     srand(time(NULL));
  10.     for(i=0; i<n; i++)
  11.  
  12.     {
  13.         for(j=0; j<n; j++)
  14.         {
  15.             mat[i][j] =rand()%2;
  16.             printf("%d ",mat[i][j]);
  17.         }
  18.         printf("\n");
  19.     }
  20.  
  21.     for(i=0; i<n; i++)
  22.  
  23.     {
  24.         printf("%c : ", 'A'+i);
  25.  
  26.         for(j=0; j<n; j++)
  27.  
  28.         {
  29.             if(mat[i][j]==1)
  30.                 printf("%c ",'A'+j);
  31.         }
  32.         printf("\n");
  33.     }
  34.  
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement