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