Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int n, LISTA[105];
- void createList()
- {
- cout<<"Nr de elemente ale listei: ";
- cin>>n;
- cout<<"Elementele listei: ";
- for(int i=1;i<=n;i++)
- cin>>LISTA[i];
- }
- void coutList()
- {
- for(int i=1;i<=n;i++)
- cout<<LISTA[i]<<' ';
- }
- void insertElement()
- {
- int p, e;
- cout<<"Pe ce pozitie sa se gaseasca noul element: ";
- cin>>p;
- cout<<"Ce element sa fie introdus: ";
- cin>>e;
- for(int i=p;i<=n;i++)
- LISTA[i+1]=LISTA[i];
- LISTA[p]=e;
- n++;
- }
- void deleteElement()
- {
- int p;
- cout<<"Pozitia elementului care va fi eliminat: ";
- cin>>p;
- for(int i=p;i<=n;i++)
- LISTA[p]=LISTA[p+1];
- n--;
- }
- void isVoid()
- {
- if(n==0)
- cout<<"Lista este vida";
- else
- cout<<"Lista este nevida";
- }
- void isFull()
- {
- if(n==105)
- cout<<"Lista este plina";
- if(n<105)
- cout<<"Lista nu este plina";
- }
- int main()
- {
- int b=0;
- int tasta;
- cout<<"1 pentru a crea o lista"<<'\n'<<"2 pentru a afisa lista"<<'\n'<<"3 pentru a insera un element"<<'\n'<<"4 pentru a sterge un element"<<'\n'<<"5 pentru a afisa daca lista este vida"<<'\n'<<"6 pentru a afisa deaca lista este goala"<<'\n'<<"7 pentru a opri programul"<<'\n';
- while(b==0)
- {
- cin>>tasta;
- switch(tasta)
- {
- case 1:createList();break;
- case 2:coutList();break;
- case 3:insertElement();break;
- case 4:deleteElement();break;
- case 5:isVoid();break;
- case 6:isFull();break;
- case 7:b=1;break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement