Advertisement
Guest User

Untitled

a guest
Mar 8th, 2017
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <windows.h>
  6.  
  7. using namespace std;
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14. int main()
  15. {
  16.     bool zycie = false;
  17.     string haslo,zgadula;
  18.     char a;
  19.     int licznik=0,dlugosc,ilosc_zyc=5;
  20.  
  21.     cout << "**********************************"<< endl;
  22.     cout << "Witaj w grze pod tytulem wysielec" << endl;
  23.     cout << "**********************************"<< endl;
  24.  
  25.     cout << "Podaj haslo do odganiecia" << endl;
  26.     cin>>haslo;
  27.  
  28.     dlugosc=haslo.length();
  29.  
  30.     cout<<endl<<endl;
  31.     for(int i=0;i<dlugosc;i++){
  32.         zgadula[i]='_';
  33.     }
  34.  
  35.     do{
  36.     zycie = false;
  37.     cout<<endl;
  38.     cout<< "Podaj jedna literke z hasla: ";
  39.     cin>>a;
  40.     cout<<endl;
  41.     system("CLS");
  42.     for(int j=0;j<dlugosc;j++){
  43.         if(a==haslo[j])
  44.         {
  45.             zgadula[j]=haslo[j];
  46.             zycie = true;
  47.             licznik++;
  48.         }
  49.  
  50.  
  51.  
  52.  
  53.         cout<<zgadula[j];
  54.  
  55.     }
  56.     if(zycie!=true)
  57.     {
  58.             ilosc_zyc--;
  59.         }
  60.     cout<<endl;
  61.     cout<<"Pozostala ilosc zyc:" <<ilosc_zyc;
  62.     if(ilosc_zyc==0)
  63.     {
  64.         cout<<endl;
  65.         cout<<"Przegrales koniec gry"<<endl;
  66.         return 0;
  67.     }
  68.  
  69.  
  70.     }while(licznik!=dlugosc);
  71.     cout<<endl;
  72.     cout<<"Gratulacje wygrales"<<endl;
  73.     cout<<"Haslo to :  "<<haslo<<endl;
  74.  
  75.  
  76.  
  77.     return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement