Advertisement
Guest User

cekaonica pacijenata

a guest
Mar 27th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4. #include <stack>
  5. #include <queue>
  6. #include <map>
  7. #include <set> //za gomilu
  8. #include<fstream>
  9. #include <string>
  10. using namespace std;
  11.  
  12. struct pacijent{
  13.  
  14.     string ime;
  15.     string prezime;
  16.     int id;
  17. };
  18.  
  19. queue<pacijent> prijava(queue<pacijent> &red){
  20.     cout<<"Unesi ime prezime i id"<<endl;
  21.     pacijent tmp;
  22.     cin>>tmp.ime>>tmp.prezime>>tmp.id;
  23.     red.push(tmp);
  24.  
  25.     return red;
  26.  
  27.  
  28. }
  29.  
  30. void baza_load(queue <pacijent> &red){
  31.  
  32.     ifstream fin;
  33.     fin.open("baza.txt");
  34.         while(fin){
  35.             pacijent osoba;
  36.             fin>>osoba.ime>>osoba.prezime>>osoba.id;
  37.             red.push(osoba);
  38.  
  39.         }
  40.     fin.close();
  41.  
  42. }
  43.  
  44. void baza_out(queue<pacijent> red){
  45.     ofstream fout;
  46.     fout.open("baza.txt");
  47.     for (int i=0;i<red.size();i++){
  48.         fout<<red.front().ime<<endl;
  49.         fout<<red.front().prezime<<endl;
  50.         fout<<red.front().id<<endl;
  51.     }
  52.     fout.close();
  53. }
  54. int main()
  55. {
  56.  
  57.     queue<pacijent>red;
  58.     baza_load(red);
  59.     cout<<"Dobar dan zelite li se prijaviti, birajte 1, ulazak kod doktora 2, trenutno kod doktora 3?"<<endl;
  60.     int ulaz;
  61.     cin>>ulaz;
  62.     while(ulaz!=0){
  63.         switch(ulaz){
  64.         case 1:
  65.             prijava(red);
  66.             break;
  67.         case 2:
  68.             red.pop();
  69.             cout<<"Molim slijedeceg pacijenta, gdin/gda. "<< red.front().ime <<endl;
  70.             break;
  71.         case 3:
  72.             cout<<"Trenutno je kod ljecnika "<< red.front().ime<<endl;
  73.             break;
  74.  
  75.         }
  76.         cout<<"Dobar dan zelite li se prijaviti, birajte 1, ulazak kod doktora 2, trenutno kod doktora 3?"<<endl;
  77.         cin>>ulaz;
  78.     }
  79.  
  80.     baza_out(red);
  81. system("pause");
  82.     return 0;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement