Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<windows.h>
- using namespace std;
- void init();
- void push(int n);
- void list();
- void pop();
- struct elem
- { int key;
- elem *next;
- } *start,*p,*q;
- elem* ordered(int index);
- void init()
- {
- start=NULL;
- }
- void push(int n)
- {
- p=start;
- start=new elem;
- start->key=n;
- start->next=p;
- }
- void list()
- {
- p=start;
- cout<<"\nЛист: ";
- while(p){
- cout<<p->key<<" ";
- p=p->next;
- }
- cout<<endl<<endl;
- }
- elem* ordered(int index)
- {
- p=start;
- while(index)
- {
- p=p->next;
- index--;
- }
- return p;
- }
- int size()
- {
- p=start;
- int sum=0;
- while(p->next!=NULL)
- {
- sum++;
- p=p->next;
- }
- return sum+1;
- }
- void pop()
- {
- for(int i=0;i<size();i++)
- {
- for(int j=0;j<size();j++)
- {
- if(i!=j)
- {
- if((ordered(i))->key==(ordered(j))->key)
- {
- break;
- }
- if(j==size()-1)
- {
- cout<<ordered(i)->key;
- }
- }
- }
- }
- }
- void main()
- {
- int n;
- init();
- SetConsoleCP(1251);SetConsoleOutputCP(1251);
- cout<<"Въведете число:\n";
- while(cin>>n&&n!=999)
- {
- push(n);
- }
- cout<<"\nЛист :";
- pop();
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement