Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<cstdlib>
- #include<iostream>
- #include <stack>
- #include <ctime>
- using namespace std;
- struct kolejka
- {
- int a;
- kolejka *next;
- };
- kolejka *first = NULL;
- kolejka *last = NULL;
- void push(int nowea)
- {
- if(first == NULL)
- {
- kolejka *punkt = new kolejka;
- punkt -> a = nowea;
- punkt -> next = NULL;
- last = punkt;
- first = punkt;
- }
- else
- {
- kolejka *punkt = new kolejka;
- punkt -> a = nowea;
- punkt -> next = last;
- last = punkt;
- }
- }
- int pop()
- {
- if(last != NULL)
- {
- kolejka *pelem = last;
- int a = last -> a;
- last = pelem -> next;
- delete pelem;
- return a;
- }
- else return 0;
- }
- void top()
- {
- if(first == NULL) cout << "kolejka jest pusta" << endl;
- else cout << "last = " << last -> a << endl;
- }
- ////////////////////////////////////////////////////////////////////////////////////
- main()
- {
- srand(time(NULL));
- for(int i = 0; i < 20; i++)
- {
- push(rand() % 100);
- }
- int min = first -> a;
- kolejka * wsk = first;
- do
- {
- if(wsk -> a < min) min = wsk -> a;
- wsk = wsk -> next ;
- }while(last != NULL);
- cout << "min " << min;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement