Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- struct pacjent {
- double maticni;
- char ime [20];
- char prezime[20];
- };
- #include "lista_sa_pokazivacimaL.h"
- //#include "Lista_sa_poljem.h"
- bool Unos_Pacjenata(SLista *LISTA) {
- double JMBG;
- char ime[20],prezime[20];
- cout<<"Unesite JMBG pacjenta ";
- cin>>JMBG;
- cout<<"Unesite ime pacjenta ";
- cin>>ime;
- cout<<"Unesite prezime pacjenta ";
- cin>>prezime;
- if (InsertL(JMBG,ime,prezime ,EndL(LISTA),LISTA)==1){
- cout<< "Pacjent "<<prezime<<" "<<ime<<" sa JMBG: ";
- cout<< fixed << setw( 13 )<< right << setfill( '0' ) <<JMBG <<" upisan u evidendiju"<<endl;
- return 1;
- }
- else {
- cout<< "GRESKA, pacjenta nije moguce pohraniti u listu"<<endl;
- return 0;
- }
- }
- void Mladi_od_18 (SLista *LISTA) {
- element pomocni;
- cout << "Pacjenti mladji od 18 godina..." << endl;
- cout << "JMBG\t\t\tGODINE: " << endl;
- int Br=0;
- pomocni=FirstL(LISTA);
- while (pomocni!=EndL(LISTA)) {
- if ((1010-(int(RetrieveL(pomocni,LISTA).maticni/1000000)%1000))<18){
- cout<< fixed << setw( 13 )<< right << setfill( '0' ) <<RetrieveL(pomocni,LISTA).maticni<<"\t\t"<<1010-(int(RetrieveL(pomocni,LISTA).maticni/1000000)%1000)<<endl;
- cout<<RetrieveL(pomocni,LISTA).ime<<"\t\t";
- Br++;}
- pomocni = NextL(pomocni,LISTA);
- }
- cout<<"\nMladjih od 18 ima "<<Br<<endl;
- }
- bool Brisanje_iz_evidencje (SLista *LISTA) {
- double Brisanje;
- element pomocni;
- bool izbrisan=0;
- cout<<"Unesite JMBG pacjenta kojeg zelite izbrisati ";
- cin>>Brisanje;
- pomocni=FirstL(LISTA);
- while (pomocni!=EndL(LISTA)) {
- if (RetrieveL(pomocni,LISTA).maticni==Brisanje){
- if (DeleteL(LocateL(Brisanje,LISTA),LISTA)==1){
- cout<<RetrieveL(pomocni,LISTA).ime<<"\t\t IZBRISAN"<<endl;
- izbrisan = 1;
- return 1;
- }
- else {
- cout<<"Greska kod brisanja "<<endl;
- return 0;
- }
- }
- pomocni = NextL(pomocni,LISTA);
- }
- if (izbrisan==0) { cout<<"\n Pacjent sa tim JMBG ne postoji u evidenciji i nemoguce ga je izbrisati\n"<<endl; return 0;}
- }
- void zamjena(element jedan,element dva,SLista *LISTA) {
- double JmbgA,JmbgB;
- char ImeA[20],PrezimeA[20],ImeB[20],PrezimeB[20];
- JmbgA = RetrieveL(jedan,LISTA).maticni;
- strcpy(ImeA,RetrieveL(jedan,LISTA).ime);
- strcpy(PrezimeA, RetrieveL(jedan,LISTA).prezime);
- JmbgB = RetrieveL(dva,LISTA).maticni;
- strcpy(ImeB, RetrieveL(dva,LISTA).ime);
- strcpy(PrezimeB, RetrieveL(dva,LISTA).prezime);
- InsertL(JmbgA,ImeA,PrezimeA ,dva,LISTA);
- DeleteL(NextL(dva,LISTA),LISTA);
- InsertL(JmbgB, ImeB, PrezimeB ,jedan,LISTA);
- DeleteL(NextL(jedan,LISTA),LISTA);
- }
- void Sortiranje_uzlazno (SLista *LISTA){
- int i=0;
- int godine;
- bool zastavica;
- element kraj,a;
- do {
- kraj=FirstL(LISTA);
- zastavica=true;
- while (NextL(kraj,LISTA)!=EndL(LISTA)) {
- if (RetrieveL(kraj,LISTA).maticni> RetrieveL (NextL(kraj,LISTA),LISTA).maticni) {
- zamjena(kraj,NextL(kraj,LISTA),LISTA);
- zastavica =false;
- }
- kraj = NextL(kraj,LISTA);
- }
- }while (!zastavica);
- cout <<endl<<"*****************************************************************************"<<endl;
- cout << "PACJENATi: " << endl;
- cout << "BR_PAC.\tIME\tPREZIME\t\tJMBG\t\tGODINE: " << endl;
- a=FirstL(LISTA);
- while (a!=EndL(LISTA)) {
- cout<< i+1 << "\t "<<RetrieveL(a,LISTA).ime<<"\t"<<RetrieveL(a,LISTA).prezime<<"\t ";
- cout<<right << setw( 13 ) << setfill( '0' ) << fixed <<RetrieveL(a,LISTA).maticni<<"\t\t"<<1010-(int(RetrieveL(a,LISTA).maticni/1000000)%1000)<<endl;
- i++;
- a = NextL(a,LISTA);
- }
- }
- int main()
- {
- cout.precision(0);
- int izbornik;
- SLista *LISTA;
- LISTA = new SLista;
- InitL(LISTA);
- do{
- cout <<endl<<"*****************************************************************************"<<endl;
- cout<< "1. Funkcija koja dodava zapise o pacijentu u listu pacjenata" << endl;
- cout << "2. Sadrzaj liste pacjenata pocevsi od najmanjeg maticnog broja do najveceg." << endl;
- cout << "3. Pretrazivanje liste i ispis svih pacijente mladih od 18 godina i njihovog ukupnog broja." << endl;
- cout << "4. Brisati podataka o pacijentu iz evidencije." << endl;
- cout << "5. izlaz "<<endl;
- cout <<endl<<"****************************************************************************"<<endl;
- cin>>izbornik;
- switch(izbornik){
- case 1: Unos_Pacjenata(LISTA);
- break;
- case 2: Sortiranje_uzlazno (LISTA);
- break;
- case 3: Mladi_od_18 (LISTA);
- break;
- case 4: Brisanje_iz_evidencje(LISTA); break;
- }
- }while (izbornik !=5);
- system("pause");
- return 1;
- }
Add Comment
Please, Sign In to add comment