pjobro

stack,que 27.3.

Mar 27th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.71 KB | None | 0 0
  1. ///hash tablica;prezentacija
  2. void hash_tablica()
  3. {
  4.     map<string, string>hash_tablica;
  5.  
  6.     hash_tablica.insert(make_pair("un", "admin"));
  7.     hash_tablica.insert(make_pair("pw", "12345"));
  8.  
  9.     cout << "username: " << hash_tablica["un"] << endl;
  10.     cout << "pass: " << hash_tablica["pw"] << endl;
  11. }
  12.  
  13. ///zadatak 4;
  14. int main()
  15.  
  16. int main()
  17. {
  18.     map<int, string> spil;
  19.     string boja[4] = { "Pik", "Tref", "Srce", "Karo" };
  20.     string brojka[13] = { "As", "Dvica", "Trica", "Cetvorka", "Petica",
  21.         "Sestica", "Sedmica", "Osmica", "Devetka", "Desetka", "Decko", "Kraljica", "Kralj" };
  22.  
  23.     int a;
  24.     for (int i = 0; i < 4; i++)
  25.     {
  26.         for (int j = 0; j < 13; j++,a++)
  27.         {
  28.             spil.insert(make_pair(a, boja[i]));
  29.             cout << brojka[j] << " " << spil[a] << endl;
  30.         }
  31.     }
  32.  
  33.     system("pause");
  34.     return 0;
  35. }
  36. ///zadatak 5..
  37. void heap() {
  38.     set<string>names;
  39.     string ime;
  40.     names.insert("Jure");
  41.     names.insert("Pero");
  42.     names.insert("Duro");
  43.     cout << "novi unos(0 za kraj): " << endl;
  44.     do {
  45.         cin >> ime;
  46.         if (names.find(ime) == names.end()) {
  47.             names.insert(ime);
  48.             cout << "novi unos je " << ime << endl;
  49.         }
  50.         else {
  51.             cout << "to je ime vec uneseno" << endl;
  52.         }
  53.     } while (ime != "0");
  54.    
  55.        
  56. }
  57.  
  58. #include "stdafx.h"
  59. #include <iostream>
  60. #include <stack>
  61. #include <queue>
  62. #include <string>
  63.  
  64. using namespace std;
  65.  
  66. struct pacijent {
  67.     string ime;
  68.     string prezime;
  69.     int ID;
  70. };
  71.  
  72. void stog();
  73. void checkin(queue<pacijent>&red);
  74.  
  75. int main()
  76. {
  77.     queue<pacijent>red;
  78.     checkin(red);
  79.     cout << red.front().ime;
  80.     return 0;
  81. }
  82.  
  83.  
  84. void checkin(queue<pacijent>&red){
  85.     pacijent novi_pacijent;
  86.     int izbor;
  87.     do {
  88.         cout << "unesite ime: ";
  89.         cin >> novi_pacijent.ime;
  90.         cout << "unesite prezime: ";
  91.         cin >> novi_pacijent.prezime;
  92.         cout << "unesite svoj ID: ";
  93.         cin >> novi_pacijent.ID;
  94.  
  95.         red.push(novi_pacijent);
  96.         cout << "novi pacijent(broj) ili izlaz 0: ";
  97.         cin >> izbor;
  98.     } while (izbor != 0);
  99.  
  100. }
  101.  
  102. void stog() {
  103.     stack<int> stog;
  104.     int izbor;
  105.     int brojac=0;
  106.     cin >> izbor;
  107.  
  108.     do {
  109.         cin >> izbor;
  110.         stog.push(izbor);
  111.         brojac++;
  112.     } while (izbor != 0);
  113.    
  114.         for (int i = 0; i < brojac+1; i++) {
  115.         cout << stog.top() << endl;
  116.         stog.pop();
  117.     }
  118.        
  119.    
  120. }
  121.  
  122.  
  123. /////andrej
  124. #include <iostream>
  125. #include <ctime>
  126. #include <cstdlib>
  127. #include <stack>
  128. #include <queue>
  129. #include <map>
  130. #include <set> //za gomilu
  131. #include<fstream>
  132. #include <string>
  133. using namespace std;
  134.  
  135. struct pacijent{
  136.  
  137.     string ime;
  138.     string prezime;
  139.     int id;
  140. };
  141.  
  142. queue<pacijent> prijava(queue<pacijent> &red){
  143.     cout<<"Unesi ime prezime i id"<<endl;
  144.     pacijent tmp;
  145.     cin>>tmp.ime>>tmp.prezime>>tmp.id;
  146.     red.push(tmp);
  147.  
  148.     return red;
  149.  
  150.  
  151. }
  152.  
  153. void baza_load(queue <pacijent> &red){
  154.  
  155.     ifstream fin;
  156.     fin.open("baza.txt");
  157.         while(fin){
  158.             pacijent osoba;
  159.             fin>>osoba.ime>>osoba.prezime>>osoba.id;
  160.             red.push(osoba);
  161.  
  162.         }
  163.     fin.close();
  164.  
  165. }
  166.  
  167. void baza_out(queue<pacijent> red){
  168.     ofstream fout;
  169.     fout.open("baza.txt");
  170.     for (int i=0;i<red.size();i++){
  171.         fout<<red.front().ime<<endl;
  172.         fout<<red.front().prezime<<endl;
  173.         fout<<red.front().id<<endl;
  174.     }
  175.     fout.close();
  176. }
  177. int main()
  178. {
  179.  
  180.     queue<pacijent>red;
  181.     baza_load(red);
  182.     cout<<"Dobar dan zelite li se prijaviti, birajte 1, ulazak kod doktora 2, trenutno kod doktora 3?"<<endl;
  183.     int ulaz;
  184.     cin>>ulaz;
  185.     while(ulaz!=0){
  186.         switch(ulaz){
  187.         case 1:
  188.             prijava(red);
  189.             break;
  190.         case 2:
  191.             red.pop();
  192.             cout<<"Molim slijedeceg pacijenta, gdin/gda. "<< red.front().ime <<endl;
  193.             break;
  194.         case 3:
  195.             cout<<"Trenutno je kod ljecnika "<< red.front().ime<<endl;
  196.             break;
  197.  
  198.         }
  199.         cout<<"Dobar dan zelite li se prijaviti, birajte 1, ulazak kod doktora 2, trenutno kod doktora 3?"<<endl;
  200.         cin>>ulaz;
  201.     }
  202.  
  203.     baza_out(red);
  204. system("pause");
  205.     return 0;
  206. }
  207.  
  208. ////treci zadatak iz prez///preko string refrence
  209. int main()
  210. {
  211.     string input;
  212.  
  213.     cout << "Please enter a string: ";
  214.     getline(cin, input);
  215.  
  216.     if (input == string(input.rbegin(), input.rend())) {
  217.         cout << input << " is a palindrome";
  218.     }
  219.  
  220.  
  221. }
  222.  
  223.  
  224.  
  225. ///krivo...
  226. int main()
  227. {
  228.     map<string, string>tablica;
  229.     vector<string>boja(3);
  230.     string par;
  231.     boja[0] = "tref";
  232.     boja[1] = "karo";
  233.     boja[2] = "pik";
  234.     boja[3] = "herc";
  235.     vector<string>znak(12);
  236.     znak[0] = "dvojka";
  237.     znak[1] = "trojka";
  238.     znak[2] = "cetiri";
  239.     znak[3] = "petarda";
  240.     znak[4] = "sestica";
  241.     znak[5] = "sedmica";
  242.     znak[6] = "osmica";
  243.     znak[7] = "devetka";
  244.     znak[8] = "desetka";
  245.     znak[9] = "decko";
  246.     znak[10] = "dama";
  247.     znak[11] = "kralj";
  248.     znak[12] = "AS";
  249.  
  250.     tablica.insert(znak,boja);
  251.     return 0;
  252.    
  253.  
  254. }
Add Comment
Please, Sign In to add comment