Posted By


ihranj on 11/12/12

Tagged


Statistics


Viewed 26 times
Favorited by 0 user(s)

Hranj_evidencija_zivotinja


/ Published in: C++
Save to your folder(s)

Evidencija životinja u tgovini životinja


Copy this code and paste it in your HTML
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include "lista_polje.h"
  4. //#include "lista_pokazivaci.h"
  5.  
  6. using namespace std;
  7.  
  8. //Globalne varijable
  9. int sifra = 100;
  10.  
  11. void unos(char *niz){
  12. cin.getline(niz, 50);
  13. if(cin.gcount()==1)
  14. cin.getline(niz,50);
  15. }
  16.  
  17. int noviZapis(tlista *l){
  18. system("cls");
  19. tzivotinje z;
  20. cout << "Sifra: " << sifra << endl; z.sifra = sifra;
  21. cout << "Vrsta zivotinje: "; unos(z.vrsta);
  22. cout << "Naziv zivotinje: "; unos(z.naziv);
  23. cout << "Cijena zivotinje(kn): "; cin >> z.cijena;
  24. cout << "Datum dostave: "; cin >> z.datum;
  25. cout << "Godina: "; cin >> z.godina;
  26. int test = InsertL(z, EndL(l), l);
  27. if(test==1){
  28. cout << endl << "Zapis je uspjesno dodan" << endl;
  29. sifra++;
  30. return 1;
  31. }
  32. else return 0;
  33. system("pause");
  34. }
  35.  
  36. void ispis(tzivotinje z){
  37. cout << "Sifra: " << z.sifra << endl;
  38. cout << "Vrsta: " << z.vrsta << endl;
  39. cout << "Naziv: " << z.naziv << endl;
  40. cout << "Cijena: " << z.cijena << endl;
  41. cout << "Datum dostave: " << z.datum << endl;
  42. cout << "Godina: " << z.godina << endl;
  43. cout << endl;
  44. }
  45.  
  46. void ispisSilazno(tlista *l, bool _2012=false){
  47. system("cls");
  48. int num=0;
  49. tzivotinje z;
  50. element last = PreviousL(EndL(l), l);
  51. if(EndL(l) != FirstL(l))
  52. while(true){
  53. z = RetrieveL(last, l);
  54. if(!_2012)
  55. ispis(z);
  56. else if(z.datum>23.09&&z.godina!=2011){ispis(z);
  57. num++;}
  58. else if(z.godina>2012){
  59. ispis(z);
  60. num++;
  61. }
  62. if(last == FirstL(l)) break;
  63. last = PreviousL(last, l);
  64. }
  65. if(_2012) cout << "Ukupno nakon 23.09.2012.: " << num << endl;
  66. system("pause");
  67. }
  68.  
  69. int brisanje(tlista *l)
  70. { system("cls");
  71. tzivotinje z;
  72. int status=0;
  73. cout<<"Naziv: ";
  74. cin.ignore();
  75. cin.getline(z.naziv,51);
  76. element p = LocateL(z, l);
  77. if(p!=EndL(l))
  78. status=DeleteL(p,l);
  79. else
  80. {
  81. cout<<"ne postoji!"<<endl<<endl;
  82. system("pause");
  83. }
  84. if(status==1)
  85. {
  86. cout<<"pobrisano!"<<endl<<endl;
  87. system("pause");
  88. return 1;
  89. }
  90. return 0;
  91. system("pause");
  92. }
  93. int brisanje_vrsta(tlista *l)
  94. {system("cls");
  95. tzivotinje z;
  96. int n = 0;
  97. cout<<"Vrsta: ";
  98. cin.ignore();
  99. cin.getline(z.vrsta,51);
  100. element p;
  101.  
  102. while(true) {
  103. p = LocateL(z, l);
  104. if(p == EndL(l))
  105. break;
  106. else
  107. n += DeleteL(p, l);
  108. }
  109.  
  110. if(n==0) {
  111. cout << "Nije pronadjena niti jedna" << z.vrsta << "!" << endl << endl;
  112. return 0;
  113. } else {
  114. cout << "Pobrisano je " << n <<" "<< z.vrsta << endl << endl;
  115. system("pause");
  116. return 1;
  117. }
  118. return 0;
  119. system("pause");
  120. }
  121.  
  122. int main(){
  123. tlista *l = InitL(l);
  124. int izbor;
  125.  
  126. do{
  127. system("cls");
  128. cout << "Izbornik" << endl << endl;
  129. cout << "1 - Unos novog zapisa" << endl;
  130. cout << "2 - Ispis(silazno)" << endl;
  131. cout << "3 - Ispis zivotinja dovedenih nakon 23.11.2012" << endl;
  132. cout << "4 - Brisanje po nazivu zivotinje" << endl;
  133. cout << "5 - Brisanje po vrsti zivotinje" << endl;
  134. cout << "6 - Sortiranje i ispis zapisa po cijeni i zapisu" << endl;
  135. cout << "0 - Kraj rada" << endl << endl;
  136. cout << "Vas izbor: ";
  137. cin >> izbor;
  138.  
  139. switch(izbor){
  140. case 1: noviZapis(l); break;
  141. case 2: ispisSilazno(l); break;
  142. case 3: ispisSilazno(l,1); break;
  143. case 4: brisanje(l); break;
  144. case 5: brisanje_vrsta(l); break;
  145. //case 6: sort(l); ispisSilazno(l); break;
  146. case 0: cout << "Kraj rada." << endl; break;
  147. default: cout << "Krivi unos!" << endl; system("pause");
  148. }
  149. }while(izbor);
  150.  
  151.  
  152. system("pause");
  153. return 0;
  154. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.