Advertisement
Shishu

adjacent of dfs in c

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