Advertisement
Antropex

Gra

Dec 10th, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <stdlib.h>
  4. #include <cmath>
  5. using namespace std;
  6. int koniec(int score, int scoreComp)
  7. {
  8.     int con;
  9.     system("CLS");
  10.     if(score > scoreComp)
  11.         cout << "WYGRALES!!!11111!!" << endl;
  12.     else
  13.         cout << "Hahahahaha PRZEGRYW" << endl;
  14.     cout << "Jeszcze raz?" << endl;
  15.     cout << "Jeszcze jak!==> 1" << endl;
  16.     cout << "Ide spac==> Co kolwiek" << endl;
  17.     cin >> con;
  18.  
  19.     if(con == 1)
  20.         return 1;
  21.     else
  22.         return 0;
  23. }
  24. int pomoc()
  25. {
  26.     cout << "Papier==> 1" << endl;
  27.     cout << "Kamien==> 2" << endl;
  28.     cout << "Nozyce==> 3" << endl;
  29.     cout << "Pomoc ==> 4" << endl;
  30.     cout << "Wyjscie==>9" << endl;
  31. }
  32. int main()
  33. {
  34.     int score = 0,choice,comp,scoreComp=0,diff= 0,maxdiff,absolute,con;
  35.     char words[3][10] = {"Papier","Kamien","Nozyce"};
  36.     cout << "Witaj" << endl;
  37.  
  38.     cout << "Do jakiej przewagi gramy? 0=> piaskownica" << endl;
  39.     cin >> maxdiff;
  40.     system("CLS");
  41.  
  42.  
  43.     pomoc();
  44.     comp = rand() % 3+1;
  45.     cin >> choice;
  46.     system("CLS");
  47.     while(choice != 9)
  48.     {
  49.  
  50.         absolute = abs(score - scoreComp);
  51.         if(maxdiff == absolute and maxdiff != 0)
  52.         {
  53.            con = koniec(score,scoreComp);
  54.            if(con == 1)
  55.            {
  56.                score = scoreComp = 0;
  57.                system("CLS");
  58.                 cout << "Papier, kamien, nozyce?" << endl;
  59.                 cin >> choice;
  60.            }else{
  61.                 return 0;
  62.            }
  63.         }
  64.  
  65.  
  66.  
  67.         if(choice < 0 or (choice > 4 or choice == 9))
  68.         {
  69.             cout << "Ooj oj zly klawisz" << endl;
  70.             cout << "Wprowadz ponownie" << endl;
  71.             cin >> choice;
  72.             system("CLS");
  73.         }
  74.         else{
  75.  
  76.  
  77.  
  78.         cout << "Wynik:" << score << endl;
  79.  
  80.  
  81.  
  82.         if(choice == 9)
  83.             return 0;
  84.         if(choice == 4)
  85.            {
  86.                pomoc();
  87.            }else{
  88.  
  89.        cout << "Ty   --- VS ---   Komputer" << endl;
  90.        cout << score << "--- VS ---"<< scoreComp << endl;
  91.        cout << words[choice-1] << "--- VS ---"<< words[comp-1] << endl;
  92.  
  93.         if(comp == choice)
  94.         {
  95.              cout << "remis";
  96.         }
  97.          if(choice == 1)
  98.         {
  99.             if(comp == 2)
  100.             {
  101.                 cout << "Papier przykrywa kamien WYGRALES" << endl;
  102.                 score++;
  103.             }
  104.             if(comp == 3)
  105.             {
  106.                 cout << "Nozyce przecinaja papier PRZEGRALES" << endl;
  107.                 scoreComp++;
  108.             }
  109.  
  110.         }
  111.         if(choice == 2)
  112.         {
  113.             if(comp == 1)
  114.             {
  115.                 cout << "Papier przykrywa kamien PRZEGRALES" << endl;
  116.                 scoreComp++;
  117.             }
  118.             if(comp == 3)
  119.             {
  120.                 cout << "Kamien tempi nozyce WYGRALES" << endl;
  121.                 score++;
  122.             }
  123.         }
  124.         if(choice == 3)
  125.         {
  126.             if(comp == 1)
  127.             {
  128.                 cout << "Nozyce tna papier WYGRALES" << endl;
  129.                 score++;
  130.             }
  131.             if(comp == 2)
  132.             {
  133.                 cout << "Kamien tempi nozyce PRZEGRALES" << endl;
  134.                 scoreComp++;
  135.  
  136.             }
  137.         }
  138.  
  139.            }
  140.  
  141.         comp = rand() % 3+1;
  142.         cin >> choice;
  143.         system("CLS");
  144. }
  145.     }
  146.     return 0;
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement