karlangadas

ALGORITMIA 2016-1 EX2 pregunta 6

Dec 1st, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. //El vertice 3
  4. int grafo[6][6]={{1,1,1,0,0,1},
  5.                  {1,0,1,1,0,0},
  6.                  {0,0,0,0,0,0},
  7.                  {0,1,1,1,0,1},
  8.                  {1,0,1,0,0,0},
  9.                  {0,1,1,1,0,0}};
  10. int filaEsCeroycolumnaesUno(int vert,int nvertices){
  11.     for (int j=0;j<nvertices;j++){
  12.         if (vert==j && grafo[vert][j]==1)
  13.             return 0;
  14.         if (vert!=j && (grafo[j][vert]!=1 || grafo[vert][j]!=0))
  15.             return 0;
  16.     }
  17.     return 1;
  18. }
  19.  
  20. int existeij(int nvertices){
  21.     for (int i=0;i<nvertices;i++){
  22.         if (filaEsCeroycolumnaesUno(i,nvertices))
  23.             return 1;
  24.     }
  25.     return 0;
  26. }
  27. int main(){
  28.     int nvertices=6;
  29.     printf("%d\n",existeij(nvertices));
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment