Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. prima problema la lab 4 asd:
  2. #include <iostream>
  3.  
  4. using namespace std;
  5. struct Nod{
  6. int info;
  7. Nod *link;
  8.  
  9. };
  10.  
  11.  
  12. Nod *HEAD=NULL;
  13.  
  14. void creareLista(int n);
  15. void afisareLista();
  16. int main()
  17. {
  18. int n,opt;
  19. cout<<"n;";
  20. cin>>n;
  21. creareLista(n);
  22. afisareLista();
  23.  
  24. return 0;
  25. }
  26. void creareLista(int n){
  27. for(int i=0;i<n;i++){
  28. Nod *p=new Nod;
  29. cin>>p->info;
  30. p->link=HEAD;
  31. HEAD=p;
  32.  
  33. }
  34.  
  35. }
  36. void afisareLista(){
  37. for(Nod *iter=HEAD;iter!=NULL;iter=iter->link){
  38. cout<<iter->info<<"->";
  39.  
  40.  
  41. }cout<<"NULL"<<endl;
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement