Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.29 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstdlib>
  4. #include <string>
  5. #include <cstring>
  6. #include <ctime>
  7.  
  8. using namespace std;
  9.  
  10. typedef void(*funkcija)();
  11.  
  12.  
  13. struct igralec
  14. {
  15.     string ime;
  16.     int vpisna_stevilka;
  17.     string ugibane_besede;
  18.     string ugibane_crke;
  19.     int potreben_cas;
  20. }Igralec_1,Igralec_2,Igralec_3,Igralec_4,Igralec_5;
  21.  
  22. void scenarij_0()
  23. {
  24.  
  25. }
  26.  
  27. void scenarij_1()
  28. {
  29.  
  30.     cout <<
  31.         "____ \n";
  32. }
  33.  
  34. void scenarij_2()
  35. {
  36.     cout <<
  37.         " |    \n"
  38.         " |    \n"
  39.         " |    \n"
  40.         " |    \n"
  41.         " |    \n"
  42.         " |    \n"
  43.         "_|___ \n";
  44. }
  45.  
  46.  
  47. void scenarij_3()
  48. {
  49.     cout <<
  50.         "  ________  \n"
  51.         " |          \n"
  52.         " |          \n"
  53.         " |          \n"
  54.         " |          \n"
  55.         " |          \n"
  56.         " |          \n"
  57.         "_|___       \n";
  58. }
  59.  
  60. void scenarij_4()
  61. {
  62.     cout <<
  63.         "  ________  \n"
  64.         " |       |  \n"
  65.         " |          \n"
  66.         " |          \n"
  67.         " |          \n"
  68.         " |          \n"
  69.         " |          \n"
  70.         "_|___       \n";
  71. }
  72.  
  73. void scenarij_5()
  74. {
  75.     cout <<
  76.         "  ________  \n"
  77.         " |       |  \n"
  78.         " |      (_) \n"
  79.         " |          \n"
  80.         " |          \n"
  81.         " |          \n"
  82.         " |          \n"
  83.         "_|___       \n";
  84. }
  85.  
  86. void scenarij_6()
  87. {
  88.     cout <<
  89.         "  ________  \n"
  90.         " |       |  \n"
  91.         " |      (_) \n"
  92.         " |       |  \n"
  93.         " |       |  \n"
  94.         " |          \n"
  95.         " |          \n"
  96.         "_|___       \n";
  97. }
  98.  
  99. void scenarij_7()
  100. {
  101.     cout <<
  102.         "  ________  \n"
  103.         " |       |  \n"
  104.         " |      (_) \n"
  105.         " |      \\| \n"
  106.         " |       |  \n"
  107.         " |          \n"
  108.         " |          \n"
  109.         "_|___       \n";
  110. }
  111.  
  112. void scenarij_8()
  113. {
  114.     cout <<
  115.         "  ________   \n"
  116.         " |       |   \n"
  117.         " |      (_)  \n"
  118.         " |      \\|/ \n"
  119.         " |       |   \n"
  120.         " |           \n"
  121.         " |           \n"
  122.         "_|___        \n";
  123. }
  124.  
  125. void scenarij_9()
  126. {
  127.     cout <<
  128.         "  ________   \n"
  129.         " |       |   \n"
  130.         " |      (_)  \n"
  131.         " |      \\|/ \n"
  132.         " |       |   \n"
  133.         " |      /    \n"
  134.         " |           \n"
  135.         "_|___        \n";
  136. }
  137.  
  138. void scenarij_10()
  139. {
  140.     cout <<
  141.         "  ________   \n"
  142.         " |       |   \n"
  143.         " |      (_)  \n"
  144.         " |      \\|/ \n"
  145.         " |       |   \n"
  146.         " |      / \\ \n"
  147.         " |           \n"
  148.         "_|___        \n KONEC IGRE!";
  149. }
  150.  
  151. bool preveri(string geslo, char poiskus, string & resitev)
  152. {
  153.     bool ok = 0;
  154.     for (int i = 0; i<geslo.length(); i++)
  155.     {
  156.         if (poiskus == geslo[i])
  157.         {
  158.             resitev[i] = poiskus;
  159.             ok = 1;
  160.         }
  161.     }
  162.     if (ok == 1)
  163.         return 1;
  164.     else
  165.         return 0;
  166. }
  167.  
  168. bool poizkusi(string geslo)
  169. {
  170.     char poiskus;
  171.     int i = 0;
  172.     char narobe[10];
  173.     string resitev;
  174.  
  175.     resitev.resize(geslo.length(), '_');
  176.     cout << "Resitev: " << resitev << endl;
  177.  
  178.     funkcija scenarij[] = {
  179.         scenarij_0,
  180.         scenarij_1,
  181.         scenarij_2,
  182.         scenarij_3,
  183.         scenarij_4,
  184.         scenarij_5,
  185.         scenarij_6,
  186.         scenarij_7,
  187.         scenarij_8,
  188.         scenarij_9,
  189.         scenarij_10
  190.     };
  191.  
  192.     do
  193.     {
  194.         cout << "Vnesi crko: ";
  195.         cin >> poiskus;
  196.  
  197.         if (preveri(geslo, poiskus, resitev) == 1)
  198.         {
  199.             system("cls");
  200.             cout << "PRAVILNO!" << endl;
  201.             scenarij[i]();
  202.             cout << "Resitev: " << resitev << endl;
  203.             cout << "Napacne crke: ";
  204.  
  205.             for (int j = 0; j<10 && narobe[j] != 0; j++)
  206.                 cout << narobe[j] << " ";
  207.  
  208.             cout << endl;
  209.  
  210.             if (geslo == resitev)
  211.                 return 1;
  212.         }
  213.         else
  214.         {
  215.             narobe[i] = poiskus;
  216.             i++;
  217.             system("cls");
  218.             cout << "NAROBE" << endl;
  219.             scenarij[i]();
  220.             cout << "Resitev: " << resitev << endl;
  221.             cout << "Napacne crke: ";
  222.  
  223.             for (int j = 0; j<10 && narobe[j] != 0; j++)
  224.                 cout << narobe[j] << " ";
  225.  
  226.             cout << endl;
  227.  
  228.         }
  229.     } while (i<10);
  230.     return 0;
  231. }
  232.  
  233. int main()
  234. {  
  235.    
  236.  
  237.     srand(time(NULL));
  238.     string gesla[100] = {
  239.         "abeceda"
  240.         "uran",
  241.         "postelja",
  242.         "orhideja",
  243.         "kljucavnica",
  244.         "okvir",
  245.         "miza",
  246.         "okras",
  247.         "kolo",
  248.         "stol",
  249.         "steklenica",
  250.         "barva",
  251.         "stojalo",
  252.         "skatla",
  253.         "ventilator",
  254.         "obutev",
  255.         "pokrov",
  256.         "hranilnik",
  257.         "nit",
  258.         "noht",
  259.         "zapestnica",
  260.         "ogrinjalo",
  261.         "oko",
  262.         "mreza",
  263.         "medalja",
  264.         "drevo",
  265.         "svecnik",
  266.         "kamen",
  267.         "lucka",
  268.         "sponka",
  269.         "prostor",
  270.         "komoda",
  271.         "toaleta",
  272.         "knjiznica",
  273.         "susilnik",
  274.         "likalnik",
  275.         "trenirka",
  276.         "drevored",
  277.         "plakat",
  278.         "svecanost",
  279.         "radiator",
  280.         "stikalo",
  281.         "vticnica",
  282.         "prevleka",
  283.         "kartoteka",
  284.         "jopic",
  285.         "onesposobiti",
  286.         "brivnik",
  287.         "paralizator",
  288.         "svetilka",
  289.         "vlomilec",
  290.         "racunalnik",
  291.         "omrezje",
  292.         "posnetek",
  293.         "premozenje",
  294.         "kriminalka",
  295.         "televizija",
  296.         "prodajalka",
  297.         "tehnologija",
  298.         "sprehod",
  299.         "varovanje",
  300.         "posel",
  301.         "diplomat",
  302.         "imuniteta",
  303.         "zuzelka",
  304.         "sporocilo",
  305.         "datoteka",
  306.         "oskrbnik",
  307.         "kamera",
  308.         "casopis",
  309.         "klient",
  310.         "kompresor",
  311.         "model",
  312.         "eksplozija",
  313.         "komar",
  314.         "skodelica",
  315.         "kravata",
  316.         "nadstropje",
  317.         "prizorisce",
  318.         "predsednik",
  319.         "komunikacija",
  320.         "gorivo",
  321.         "postrv",
  322.         "baterija",
  323.         "naslonjalo",
  324.         "podatek",
  325.         "tetovaza",
  326.         "restavracija",
  327.         "opozorilo",
  328.         "kilometer",
  329.         "vozilo",
  330.         "odbor",
  331.         "pisarna",
  332.         "virus",
  333.         "policist",
  334.         "popravilo",
  335.         "pomanjkanje",
  336.         "oderuh",
  337.         "prtljaznik",
  338.         "menjalnik"
  339.     };
  340.  
  341.     int indeks = rand() % 100 + 0;
  342.     if (poizkusi(gesla[indeks]) == 1)
  343.         cout << endl << "BRAVO" << endl;
  344.     else
  345.         cout << endl << "OJOJ" << endl;
  346.  
  347.     {
  348.         clock_t t;
  349.         t = clock();
  350.         t = clock() - t;
  351.         cout << "Vas cas je: " << t, ((float)t) / CLOCKS_PER_SEC) << "s." << endl;
  352.         return 0;
  353.        
  354.     }
  355.  
  356.     return 0;
  357.    
  358. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement