Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- struct pac {
- int mbr, god;
- char ime[20], prez [25];
- }p;
- struct lista {
- pac P [50];
- int end;
- }L;
- int FirstL(lista *L) {
- return 0;
- };
- int EndL(lista *L) {
- return L->end;
- };
- int NextL(int p, lista *L) {
- if(L->end == 0) {
- cout << "Lista je prazna" << endl;
- return 0;
- }
- else {
- int i;
- i = p + 1;
- return i;}
- };
- int PreviousL(int p, lista *L) {
- if(L->end == 0) {
- cout << "Lista je prazna" << endl;
- return 0;
- }
- else{
- int i;
- i = p - 1;
- return i;}
- };
- int LocateL(int x, lista *L) {
- if(L->end == 0) {
- cout << "Lista je prazna" << endl;
- return 0;
- }
- else {
- int i;
- i = 0;
- while((i != L->end) && (L->P[i].mbr != x))
- i++;
- return i;}
- };
- int InsertL(pac x, int p, lista *L) {
- int i;
- if(L->end == 50) {
- cout << "Lista je puna" << endl;
- return 0;
- }
- else {
- L->P[p].mbr = x.mbr;
- L->P[p].god = x.god;
- strcpy(L->P[p].ime, x.ime);
- strcpy(L->P[p].prez, x.prez);
- L->end++;
- return 1;
- }
- };
- int DeleteL(int p, lista *L) {
- int izb = 0, bmbr, bpoz;
- cout << "Upisite Maticni broj pacijenta kojeg zelite obrisati: " ;
- cin >> bmbr;
- if(L->end == 0) {
- cout<<"Lista je prazna"<<endl;
- return 0; }
- int end = EndL(L);
- while (p < end){
- if (L->P[p].mbr == bmbr) {
- bpoz = p;
- izb = 1;}
- p++;}
- if(izb == 1){
- for(int i = bpoz; i < L->end; i++) L->P [i] = L->P[i+1];
- L->end--;
- return 1;}
- else {
- cout << "Pacijent s upisanim maticnim brojem ne postoji" << endl;
- return 0; }
- };
- pac RetrieveL(int p, lista *L) {
- if(L->end == 0) {
- cout << "Lista je prazna" << endl;
- exit(0);
- }
- else {
- return(L->P[p]);}
- };
- void DeleteAllL(lista *L) {
- L->end = 0;
- };
- void sort (lista *L){
- int pom;
- lista PL;
- int n = EndL(L);
- for (int i = 0; i < n; i++){
- PL.P[i] = L->P[i];}
- for (int i = 1; i < n; i++){
- int j = i - 1;
- int pom = L->P[i].mbr;
- while (j >= 0 && L->P[j].mbr > pom){
- L->P[j+1].mbr = L->P[j--].mbr;}
- L->P[j+1].mbr = pom;}
- for (int i = 0; i < n; i++){
- for (int j = 0; j < n; j++){
- if (L->P[i].mbr == PL.P[j].mbr) L->P[i] = PL.P[j];}}
- };
- int pret (lista *L){
- int n = EndL(L);
- int br = 0;
- for (int i = 0; i < n; i++){
- if (L->P[i].god < 18){
- cout << endl << "Maticni broj: " << L->P[i].mbr << endl;
- cout << "Ime: " << L->P[i].ime << endl;
- cout << "Prezime: " << L->P[i].prez << endl;
- cout << "Godine: " << L->P[i].god << endl;
- br++;}}
- return br;
- };
- void isp(lista *L){
- int pos = FirstL(L);
- int poss = EndL(L);
- cout << "--Ispis sadrzaja liste od najmanjeg maticnog broja--" << endl;
- cout << "----------------------------------------------------" ;
- while (pos < poss && pos >= 0){
- cout << endl << "Maticni broj: " << L->P[pos].mbr << endl;
- cout << "Ime: " << L->P[pos].ime << endl;
- cout << "Prezime: " << L->P[pos].prez << endl;
- cout << "Godine: " << L->P[pos].god << endl;
- pos++;}
- };
Add Comment
Please, Sign In to add comment