Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct kolejka{
- int data;
- kolejka * next;
- };
- void dodaj(kolejka *&head, kolejka *&tail, int n)
- {
- kolejka *temp = new kolejka;
- temp->data = n;
- if (head == NULL)
- {
- head = temp;
- temp->next = NULL;
- tail = head;
- }
- else
- {
- temp->next = tail;
- tail = temp;
- }
- }
- void podz(int n,int *tab,int k, kolejka *&head, kolejka *&tail)
- {
- for (int i = 0; i < n; i++)
- {
- if (tab[i] % k == 0) dodaj(head, tail, tab[i]);
- }
- }
- void wys(kolejka *head, kolejka *tail)
- {
- while (tail != NULL)
- {
- cout << tail->data;
- tail = tail->next;
- }
- }
- int main()
- {
- kolejka *head = NULL;
- kolejka *tail = NULL;
- int tab[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
- podz(10, tab, 2, head, tail);
- wys(head, tail);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement