fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. typedef struct Baza
  5. {
  6. int liczba;
  7. struct Baza *next;
  8. }el;
  9.  
  10. typedef struct Baza2
  11. {
  12. int liczba_mod;
  13. struct Baza2 *n;
  14. }el2;
  15.  
  16. el *head = NULL;
  17. el2 *pocz = NULL;
  18.  
  19. void dodaj( el*&head,int x )
  20. {
  21. el *tmp = (el *)malloc(sizeof(el));
  22. tmp->liczba = x;
  23. tmp->next=head;
  24. head = tmp;
  25. }
  26.  
  27. void edytuj(el2**pocz)
  28. {
  29. el *tmp = head;
  30.  
  31.  
  32. while( tmp != NULL)
  33. {
  34. el2 *wsk = (el2 *)malloc(sizeof(el2));
  35.  
  36. if( (tmp->liczba)%3==0 )
  37. {
  38. wsk->liczba_mod = tmp->liczba;
  39. wsk->n = *pocz;
  40. *pocz = wsk;
  41. }
  42. tmp=tmp->next;
  43. }
  44. }
  45. void wypisz(el2 *adres_pocz)
  46. {
  47. el2 *wsk = adres_pocz;
  48. while( wsk != NULL)
  49. {
  50. printf(" %d ",wsk->liczba_mod);
  51. wsk=wsk->n;
  52. }
  53. }
  54.  
  55. int main()
  56. {
  57. int i;
  58. for(i=1;i<=10;i++)
  59. dodaj(head,i);
  60.  
  61. edytuj(&pocz);
  62. wypisz(pocz);
  63. }
Success #stdin #stdout 0s 2984KB
stdin
Standard input is empty
stdout
 3  6  9