Guest User

Untitled

a guest
Mar 8th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 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. int main()
  10. {
  11. bool zycie = false;
  12. string haslo,zgadula;
  13. char a;
  14. int licznik=0,dlugosc,ilosc_zyc=5;
  15.  
  16. cout << "**********************************"<< endl;
  17. cout << "Witaj w grze pod tytulem wisielec" << endl;
  18. cout << "**********************************"<< endl;
  19.  
  20. cout << "Podaj haslo do odganiecia" << endl;
  21. cin>>haslo;
  22.  
  23. dlugosc=haslo.length();
  24.  
  25. cout<<endl<<endl;
  26. for(int i=0;i<dlugosc;i++){
  27. zgadula[i]='_';
  28. }
  29. do{
  30. zycie = false;
  31. cout<<endl;
  32. cout<< "Podaj jedna literke z hasla: ";
  33. cin>>a;
  34. cout<<endl;
  35. system("CLS");
  36. for(int j=0;j<dlugosc;j++){
  37. if(a==haslo[j])
  38. {
  39. zgadula[j]=haslo[j];
  40. zycie = true;
  41. licznik++;
  42. }
  43. cout<<zgadula[j];
  44. }
  45. if(zycie!=true)
  46. {
  47. ilosc_zyc--;
  48. }
  49. cout<<endl;
  50. cout<<"Pozostala ilosc zyc:" <<ilosc_zyc;
  51. if(ilosc_zyc==0)
  52. {
  53. cout<<endl;
  54. cout<<"Przegrales koniec gry"<<endl;
  55. return 0;
  56. }
  57.  
  58. }while(licznik!=dlugosc);
  59. cout<<endl;
  60. cout<<"Gratulacje wygrales"<<endl;
  61. cout<<"Haslo to : "<<haslo<<endl;
  62. return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment