Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream> //cout, cin-hez kell
- #include <stdlib.h> //rand-hoz kell
- #include <time.h> //time-hoz kell -> a veletlengenerator inicializalasa
- using namespace std;
- int main()
- {
- //Barkochba
- int v;
- int tipp;
- srand(time(NULL));
- v=rand() % 100 +1;
- cout << v << endl;
- do
- {
- cout << "Tipp: ";
- cin >> tipp;
- if (tipp < v)
- {
- cout << "Kisebb!\n";
- }else if (tipp > v)
- {
- cout << "Nagyobb!\n";
- }
- }
- while (tipp!=v);
- cout << "Ugyes vagy!" << endl;
- //Faktorialis
- int nfaktor;
- float eredmeny = 1; // mert nagyon nagy szam is lehet
- cout << "Add meg a szamot! ";
- cin >> nfaktor;
- if (nfaktor < 0)
- {
- cout << "Nem lehet 0-nal kisebb!";
- return -1;
- }
- for (int i=1; i <= nfaktor; i++)
- {
- eredmeny *= i;
- }
- cout << nfaktor << "! = " << eredmeny << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment