Guest User

Atspek

a guest
Mar 2nd, 2014
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <cstdlib>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.        
  7. int main(){
  8. setlocale(LC_ALL, "Lithuanian");
  9. int sk, spejimas, riba, spej, spejimai[10];
  10. spej = 0;
  11. cout << "Įveskite ribą: ";
  12. cin >> riba;
  13. sk = rand() % riba;
  14. cout << sk << endl;
  15. spejimas = -1;
  16.  
  17.     while (spejimas!=sk && spej<=4){
  18.    
  19.     cout << spej+1 <<" Spėjimas: Spėkite skaičių: ";
  20.     cin >> spejimas;
  21.  
  22.     spejimai[spej] = spejimas;
  23.  
  24.     if (spejimas>sk){
  25.         cout << "Spėjimas per didelis" << endl;
  26.     }
  27.  
  28.     else{
  29.         cout << "Spėjimas per mažas" << endl;
  30.     }
  31.  
  32.     spej++;
  33.     }
  34.  
  35.     if (spejimas==sk){
  36.         cout << "" << endl;
  37.         cout << "Atspėjote!" << endl;
  38.     }
  39.     else{
  40.         cout << "" << endl;
  41.         cout << "Per daug neteisingų spėjimų."<<endl;
  42.         cout << "" << endl;
  43.     }
  44.  
  45. cout << "Jūsų spėjimai: ";
  46. int skaitliukas = 0;
  47. while (skaitliukas != spej){
  48.     cout << spejimai[skaitliukas] << " ";
  49.     skaitliukas++;
  50. }
  51.  
  52. cout << endl;
  53. system("pause");
  54. }
Advertisement
Add Comment
Please, Sign In to add comment