Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct pacijent{
- int matbr;
- int dob;
- };
- struct tpacijenti{
- pacijent pacijenti[300];
- int kursor;
- };
- void InitL(tpacijenti *lista){
- lista->kursor=0;
- }
- int FirstL(tpacijenti *lista){
- return 0;
- }
- int EndL(tpacijenti *lista){
- return lista->kursor;
- }
- int NextL(int p, tpacijenti *lista){
- if(p==lista->kursor-1) return EndL(lista);
- if (p>=lista->kursor) cout << "Greska lista nije definirana"<<endl;
- else{
- cout << "Maticni broj pacijenta "<<lista->pacijenti[p+1].matbr;
- cout << "Dob pacijenta "<<lista->pacijenti[p+1].dob;
- }
- }
- void PreviousL(int p, tpacijenti *lista){
- if(p==lista->kursor) {
- cout << "Maticni broj pacijenta "<<lista->pacijenti[lista->kursor-1].matbr;
- cout << "Dob pacijenta "<<lista->pacijenti[lista->kursor-1].dob;
- }
- else{
- if (p<=0 || p>lista->kursor) cout << "Greska lista nije definirana"<<endl;
- else{
- cout << "Maticni broj pacijenta "<<lista->pacijenti[p-1].matbr;
- cout << "Dob pacijenta "<<lista->pacijenti[p-1].dob;
- }
- }
- }
- int LocateL(int x, tpacijenti *lista){
- for (int i=0;i<lista->kursor;i++){
- if (lista->pacijenti[i].matbr==x) return i;
- }
- return EndL(lista);
- }
- void InsertL(pacijent x, int p, tpacijenti *lista){
- if(p>=0 && p<=lista->kursor){
- lista->kursor++;
- for (int i=lista->kursor-1;i>=p;i--){
- lista->pacijenti[i]=lista->pacijenti[i-1];
- }
- lista->pacijenti[p]=x;
- }
- else cout << "Niste unijeli dobru poziciju"<<endl;
- }
- void Insert(pacijent x, tpacijenti *lista){
- lista->pacijenti[lista->kursor]=x;
- lista->kursor++;
- }
- void DeleteL(int p, tpacijenti *lista){
- if(p>=0 && p<=lista->kursor){
- for (int i=p;i<lista->kursor-1;i++){
- lista->pacijenti[i]=lista->pacijenti[i+1];
- }
- lista->kursor--;
- }
- else cout << "Niste unijeli dobru poziciju"<<endl;
- }
- pacijent RetrieveL(int p, tpacijenti *lista){
- if (p<0 || p>=lista->kursor) cout << "Krivo unesena pozicija"<<endl;
- else return lista->pacijenti[p];
- }
- void DeleteAllL(tpacijenti *lista){
- lista->kursor=0;
- }
- void sort(tpacijenti *lista){
- for (int i=1; i<lista->kursor; i++){
- int j=i-1;
- pacijent pom=lista->pacijenti[i];
- while(j>=0 && lista->pacijenti[j].matbr>pom.matbr)
- lista->pacijenti[j+1]=lista->pacijenti[j--];
- lista->pacijenti[j+1]=pom;
- }
- }
- void ispis(tpacijenti *lista){
- for(int i=0;i<lista->kursor;i++){
- cout << "Maticni broj je "<<lista->pacijenti[i].matbr<<endl;
- cout << "Dob je "<<lista->pacijenti[i].dob<<endl;
- cout <<"-------------------"<<endl;
- }
- }
- void ispisgodine(tpacijenti *lista){
- int brojac=0;
- for (int i=0;i<lista->kursor;i++){
- if (lista->pacijenti[i].dob<18){
- cout << "Maticni broj: "<<lista->pacijenti[i].matbr<<endl;
- cout << "Dob: "<<lista->pacijenti[i].dob<<endl;
- cout << "----------------"<<endl;
- brojac++;
- }
- }
- cout << "Mladih od 18 ima "<<brojac<<endl;
- }
- int Delete(tpacijenti *lista, int matbr){
- for (int i=0;i<lista->kursor;i++){
- if(lista->pacijenti[i].matbr==matbr){
- for (int j=i;j<lista->kursor-1;j++){
- lista->pacijenti[j]=lista->pacijenti[j+1];
- }
- lista->kursor--;
- return 1;
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment