rana1704

Graph_Random

Oct 5th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int num_of_nodes;
  5. printf("Enter the Number of NODE: " );
  6. scanf("%d",&num_of_nodes);
  7. int i,j,graph[50][50];
  8. for(i=0;i<num_of_nodes;i++)
  9. {
  10.     for(j=0;j<num_of_nodes;j++)
  11.     {
  12.         if(i!=j)
  13.         {
  14.             int num=rand()%2;
  15.             graph[i][j]=num;
  16.         }
  17.         else
  18.         {
  19.             graph[i][j]=0;
  20.         }
  21.     }
  22. }
  23. for ( i=0;i<num_of_nodes;i++)
  24.     {
  25.         for (j=0;j<num_of_nodes;j++)
  26.         {
  27.             printf("%d ",graph[i][j]);
  28.         }
  29.         printf("\n");
  30.     }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment