lisachu

Gnp

Nov 28th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. void Gnp(int n, float p, t2 A)
  2. {
  3.    int i, j;
  4.    enum Boolean x;
  5.  
  6.    for (i = 1; i <= n; i++) A[i][i] = falsz;
  7.    for (i = 1; i <= n - 1; i++)
  8.        for (j = i + 1; j <= n; j++)
  9.        {
  10.            x = Boolean(Random() <= p);
  11.            A[i][j] = x;
  12.            A[j][i] = x;
  13.        }
  14. } //Gnp
  15.  
  16. void PrintMatrixR(int n, t2 A)
  17. {
  18.    int i, j;
  19.  
  20.    for (i = 1; i <= n; i++) {
  21.        printf("[");
  22.        for (j = 1; j <= n; j++) {
  23.            if (A[i][j]) printf("1"); else printf("0");
  24.            if (j<n) printf(",");
  25.        }
  26.         printf("]\n");
  27.    }
  28.  
  29. } //DrukR
Add Comment
Please, Sign In to add comment