Advertisement
Guest User

Untitled

a guest
Apr 30th, 2015
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <cstdlib> //funkcja rand
  4. #include <time.h>
  5.  
  6. using namespace std;
  7.  
  8.  
  9. int liczba, strzelaj;
  10.  
  11. int main()
  12. {
  13.  
  14. cout<<"Witamy w losowaniu! Wybierz sobie liczbe w przedziale 1..100:"<<endl;
  15. cout<<"Podaj liczbe z tego przedzialu: "<<endl;
  16. cin>>strzelaj;
  17.  
  18.  
  19. srand(time(NULL)); //start randomaizing, zacznij generowac liczy losowe
  20. liczba= rand()% 100+1;
  21.  
  22. /* funkcja rand() oznacza przedzial dla 100 sa to liczby 0-99, wiec*/ // musimy dodac 1,
  23.  
  24. while(strzelaj!=liczba)
  25. {
  26.  
  27. if(strzelaj>liczba)
  28. {
  29. cout<<"TWOJA liczba jest za duza "<<endl;
  30. }
  31. else if(strzelaj == liczba)
  32. {
  33. cout<<"Wygrales, liczba podana przez Ciebie jest prawidlowa"<<endl;
  34. }
  35. else if(strzelaj < liczba)
  36. {
  37. cout<<"Twoja liczba jest za mala. "<<endl;
  38. }
  39.  
  40. }
  41. cout<<"wypiszesz to gnoju"<<endl;
  42. return 0;
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement