Advertisement
MirandaWopps

T14

Jun 27th, 2022 (edited)
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.42 KB | None | 0 0
  1. #define TOT_VERT 5
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5.  
  6. typedef struct node Node;
  7. typedef struct graph Graph;
  8. typedef struct edge Edge;
  9. struct node {
  10.     Edge* final_aresta;
  11.     Node* prox;
  12. };
  13.  
  14. struct graph {
  15.     Node* vetor[TOT_VERT];
  16. };
  17.  
  18. struct edge {
  19.     int vert_arest_inicial;
  20.     int vert_arest_final;
  21. };
  22.  
  23.  
  24. Graph** criaGraph(Graph* p, int qtd) {
  25.     p = NULL;
  26.     for (int i = 0; i < qtd; i++) {
  27.         p[i] ;
  28.     }
  29.  
  30. }
  31.  
  32. int verifica(Graph * p, int ini, int fim ){
  33.     if (p->vetor[] <= fim ) {
  34.         return 0 ;
  35.     }
  36.     return 1;
  37. }
  38. Node* criaLista() {
  39.     Node* lst;
  40.     lst = NULL;
  41.     return lst;
  42. }
  43.  
  44.  
  45.  
  46.  
  47. Node* insere(Node* lst, int id) {
  48.     Node* p;
  49.     p = (Node*)malloc(sizeof(Node));
  50.     if (p == NULL) return NULL;
  51.  
  52.     p->ponta_final_aresta->vert_arest_final = id;
  53.     p->prox = lst;
  54.  
  55.     return p;
  56. }
  57.  
  58. void lista_exibe(Graph** g) {
  59.  
  60.     for (int i; g[i] != NULL; i++) {
  61.         for (g[i] = ponta_final_aresta; ponta_final_aresta != NULL; Edge * g[i] = g[i]) {}
  62.         printf("(%d -> %d)     ", g[i].ponta_final_aresta->vert_arest_inicial    ,      g[i].node->ponta_final_aresta->vert_arest_final);
  63.  
  64.     }
  65.  
  66. }
  67.  
  68.  
  69.  
  70. int main() {
  71.     Graph* v[] = { 0, 1 ,2 ,3 ,4, 5 };
  72.  
  73.     Node* lst;
  74.     lst = criaLista();
  75.  
  76.     Edge edges1[] ={  {0,1}, {1,2}, {2,0}, {2,1}, {3,1}, {4,2}  };
  77.  
  78.     lst = criaLista();
  79.     lst = insere(lst, 1);
  80.     lst = insere(lst, 3);
  81.     lst = insere(lst, 5);
  82.     lst = insere(lst, 7);
  83.  
  84.     lista_exibe(lst);
  85.  
  86.     return 0;
  87. }
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement