Advertisement
Guest User

Untitled

a guest
May 21st, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. struct nod
  5. {
  6.  
  7. int info;
  8. nod* urm;
  9. };
  10. int n,i;
  11. nod *p,*prim,*ultim;
  12. void creare()
  13. {
  14. cin>>n;
  15. for(i=1;i<=n;i++)
  16. {
  17. p=new nod;
  18. p->urm=NULL;
  19. cin>>p->info;
  20. if(prim==NULL)
  21. {
  22. prim=p;
  23. ultim=p;
  24.  
  25. }
  26. else{
  27. ultim->urm=p;
  28. ultim=p;
  29. }
  30. }
  31.  
  32. }
  33. int sub(nod* lala,int k)
  34. {nod *ehe;
  35. int nr=0;
  36. for(ehe=lala;ehe!=NULL;ehe=ehe->urm)
  37. {
  38. if(k>=ehe->info)
  39. {
  40. nr++;
  41. }
  42. }
  43. return nr;
  44.  
  45. }
  46. int main()
  47.  
  48. {int p;
  49. creare();
  50. cin>>p;
  51. nod* op;
  52. /*for(op=prim;op!=NULL;op=op->urm)
  53. cout<<op->info<<" ";*/
  54.  
  55. cout<<sub(prim,p);
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement