Guest User

Untitled

a guest
Jun 19th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.10 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. struct pacjent {
  6. double maticni;
  7. char ime [20];
  8. char prezime[20];
  9. };
  10.  
  11. #include "lista_sa_pokazivacimaL.h"
  12. //#include "Lista_sa_poljem.h"
  13.  
  14.  
  15. bool Unos_Pacjenata(SLista *LISTA) {
  16. double JMBG;
  17. char ime[20],prezime[20];
  18. cout<<"Unesite JMBG pacjenta ";
  19. cin>>JMBG;
  20. cout<<"Unesite ime pacjenta ";
  21. cin>>ime;
  22. cout<<"Unesite prezime pacjenta ";
  23. cin>>prezime;
  24.  
  25. if (InsertL(JMBG,ime,prezime ,EndL(LISTA),LISTA)==1){
  26. cout<< "Pacjent "<<prezime<<" "<<ime<<" sa JMBG: ";
  27. cout<< fixed << setw( 13 )<< right << setfill( '0' ) <<JMBG <<" upisan u evidendiju"<<endl;
  28. return 1;
  29. }
  30. else {
  31. cout<< "GRESKA, pacjenta nije moguce pohraniti u listu"<<endl;
  32. return 0;
  33. }
  34. }
  35.  
  36.  
  37.  
  38. void Mladi_od_18 (SLista *LISTA) {
  39. element pomocni;
  40. cout << "Pacjenti mladji od 18 godina..." << endl;
  41. cout << "JMBG\t\t\tGODINE: " << endl;
  42. int Br=0;
  43. pomocni=FirstL(LISTA);
  44. while (pomocni!=EndL(LISTA)) {
  45. if ((1010-(int(RetrieveL(pomocni,LISTA).maticni/1000000)%1000))<18){
  46. cout<< fixed << setw( 13 )<< right << setfill( '0' ) <<RetrieveL(pomocni,LISTA).maticni<<"\t\t"<<1010-(int(RetrieveL(pomocni,LISTA).maticni/1000000)%1000)<<endl;
  47. cout<<RetrieveL(pomocni,LISTA).ime<<"\t\t";
  48. Br++;}
  49. pomocni = NextL(pomocni,LISTA);
  50. }
  51. cout<<"\nMladjih od 18 ima "<<Br<<endl;
  52. }
  53.  
  54.  
  55. bool Brisanje_iz_evidencje (SLista *LISTA) {
  56. double Brisanje;
  57. element pomocni;
  58. bool izbrisan=0;
  59.  
  60. cout<<"Unesite JMBG pacjenta kojeg zelite izbrisati ";
  61. cin>>Brisanje;
  62.  
  63. pomocni=FirstL(LISTA);
  64. while (pomocni!=EndL(LISTA)) {
  65. if (RetrieveL(pomocni,LISTA).maticni==Brisanje){
  66. if (DeleteL(LocateL(Brisanje,LISTA),LISTA)==1){
  67. cout<<RetrieveL(pomocni,LISTA).ime<<"\t\t IZBRISAN"<<endl;
  68. izbrisan = 1;
  69. return 1;
  70. }
  71. else {
  72. cout<<"Greska kod brisanja "<<endl;
  73. return 0;
  74. }
  75. }
  76. pomocni = NextL(pomocni,LISTA);
  77. }
  78.  
  79. if (izbrisan==0) { cout<<"\n Pacjent sa tim JMBG ne postoji u evidenciji i nemoguce ga je izbrisati\n"<<endl; return 0;}
  80. }
  81.  
  82.  
  83.  
  84. void zamjena(element jedan,element dva,SLista *LISTA) {
  85. double JmbgA,JmbgB;
  86. char ImeA[20],PrezimeA[20],ImeB[20],PrezimeB[20];
  87.  
  88. JmbgA = RetrieveL(jedan,LISTA).maticni;
  89. strcpy(ImeA,RetrieveL(jedan,LISTA).ime);
  90. strcpy(PrezimeA, RetrieveL(jedan,LISTA).prezime);
  91.  
  92. JmbgB = RetrieveL(dva,LISTA).maticni;
  93. strcpy(ImeB, RetrieveL(dva,LISTA).ime);
  94. strcpy(PrezimeB, RetrieveL(dva,LISTA).prezime);
  95.  
  96. InsertL(JmbgA,ImeA,PrezimeA ,dva,LISTA);
  97. DeleteL(NextL(dva,LISTA),LISTA);
  98. InsertL(JmbgB, ImeB, PrezimeB ,jedan,LISTA);
  99. DeleteL(NextL(jedan,LISTA),LISTA);
  100. }
  101.  
  102.  
  103. void Sortiranje_uzlazno (SLista *LISTA){
  104. int i=0;
  105. int godine;
  106. bool zastavica;
  107. element kraj,a;
  108.  
  109. do {
  110. kraj=FirstL(LISTA);
  111. zastavica=true;
  112. while (NextL(kraj,LISTA)!=EndL(LISTA)) {
  113. if (RetrieveL(kraj,LISTA).maticni> RetrieveL (NextL(kraj,LISTA),LISTA).maticni) {
  114. zamjena(kraj,NextL(kraj,LISTA),LISTA);
  115. zastavica =false;
  116. }
  117. kraj = NextL(kraj,LISTA);
  118. }
  119. }while (!zastavica);
  120.  
  121. cout <<endl<<"*****************************************************************************"<<endl;
  122. cout << "PACJENATi: " << endl;
  123. cout << "BR_PAC.\tIME\tPREZIME\t\tJMBG\t\tGODINE: " << endl;
  124. a=FirstL(LISTA);
  125.  
  126. while (a!=EndL(LISTA)) {
  127. cout<< i+1 << "\t "<<RetrieveL(a,LISTA).ime<<"\t"<<RetrieveL(a,LISTA).prezime<<"\t ";
  128. cout<<right << setw( 13 ) << setfill( '0' ) << fixed <<RetrieveL(a,LISTA).maticni<<"\t\t"<<1010-(int(RetrieveL(a,LISTA).maticni/1000000)%1000)<<endl;
  129. i++;
  130. a = NextL(a,LISTA);
  131. }
  132. }
  133.  
  134.  
  135. int main()
  136. {
  137. cout.precision(0);
  138. int izbornik;
  139.  
  140. SLista *LISTA;
  141. LISTA = new SLista;
  142. InitL(LISTA);
  143.  
  144. do{
  145. cout <<endl<<"*****************************************************************************"<<endl;
  146. cout<< "1. Funkcija koja dodava zapise o pacijentu u listu pacjenata" << endl;
  147. cout << "2. Sadrzaj liste pacjenata pocevsi od najmanjeg maticnog broja do najveceg." << endl;
  148. cout << "3. Pretrazivanje liste i ispis svih pacijente mladih od 18 godina i njihovog ukupnog broja." << endl;
  149. cout << "4. Brisati podataka o pacijentu iz evidencije." << endl;
  150. cout << "5. izlaz "<<endl;
  151. cout <<endl<<"****************************************************************************"<<endl;
  152. cin>>izbornik;
  153.  
  154. switch(izbornik){
  155. case 1: Unos_Pacjenata(LISTA);
  156. break;
  157. case 2: Sortiranje_uzlazno (LISTA);
  158. break;
  159. case 3: Mladi_od_18 (LISTA);
  160. break;
  161. case 4: Brisanje_iz_evidencje(LISTA); break;
  162. }
  163. }while (izbornik !=5);
  164. system("pause");
  165. return 1;
  166. }
Add Comment
Please, Sign In to add comment