Guest User

Untitled

a guest
Dec 13th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <iostream> //cout, cin-hez kell
  2. #include <stdlib.h> //rand-hoz kell
  3. #include <time.h> //time-hoz kell -> a veletlengenerator inicializalasa
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     //Barkochba
  10.     int v;
  11.     int tipp;
  12.  
  13.  
  14.     srand(time(NULL));
  15.  
  16.     v=rand() % 100 +1;
  17.     cout << v << endl;
  18.  
  19.     do
  20.     {
  21.         cout << "Tipp: ";
  22.         cin >> tipp;
  23.  
  24.         if (tipp < v)
  25.         {
  26.             cout << "Kisebb!\n";
  27.         }else if (tipp > v)
  28.         {
  29.             cout << "Nagyobb!\n";
  30.         }
  31.  
  32.     }
  33.     while (tipp!=v);
  34.  
  35.     cout << "Ugyes vagy!" << endl;
  36.  
  37.     //Faktorialis
  38.     int nfaktor;
  39.     float eredmeny = 1; // mert nagyon nagy szam is lehet
  40.  
  41.  
  42.     cout << "Add meg a szamot! ";
  43.     cin >> nfaktor;
  44.     if (nfaktor < 0)
  45.     {
  46.         cout << "Nem lehet 0-nal kisebb!";
  47.         return -1;
  48.     }
  49.     for (int i=1; i <= nfaktor; i++)
  50.     {
  51.         eredmeny *= i;
  52.     }
  53.  
  54.  
  55.  
  56.     cout << nfaktor << "! = " << eredmeny << endl;
  57.  
  58.  
  59.  
  60.     return 0;
  61.  
  62. }
Add Comment
Please, Sign In to add comment