Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include<iostream.h>
  2. #include<fstream.h>
  3. typedef struct nod{
  4. int inf;
  5. nod *urm;
  6. }AD; //descrierea unui element din lista
  7. AD *L[N]; //listele vecinilor
  8. void citire()
  9. {
  10. int i,j; AD *x;
  11. ifstream f(β€žin.txt”);
  12. f>>n; //numarul de varfuri
  13. for(i=1;i<=n;i++) //aloca adrese pentru listele vecinilor
  14. {
  15. L[i]=new AD; L[i]->urm=0;
  16. }
  17.  
  18. while(!feof(f))
  19. {
  20. f>>i>>j;
  21. //adaug j in lista vecinilor lui i
  22. x=new AD; x->inf=j; x->urm=L[i]->urm; L[i]->urm=x;
  23. }
  24. fclose(f);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement