Advertisement
angryatti

Pesudo(er) basic LotteryNumberGenV1 Cplusplus

Jan 3rd, 2023
1,146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. #include <set>
  5. using namespace std;
  6.  
  7. void lotteryGen(int lotteryType, int numberCount) {
  8.  
  9.  
  10.     set<int> lotteryNumber;
  11.  
  12.     while (lotteryNumber.size() != lotteryType)
  13.     {
  14.         int randtemp = rand() % numberCount + 1;
  15.  
  16.         lotteryNumber.insert(randtemp);
  17.  
  18.  
  19.     }
  20.  
  21.  
  22.     //    sort(begin(lotteryNumber), end(lotteryNumber));
  23.  
  24.  
  25.     for (auto it = lotteryNumber.begin(); it !=
  26.         lotteryNumber.end(); ++it)
  27.     {
  28.  
  29.         cout << ' ' << *it;
  30.     }
  31.     cout << "" << endl;
  32.  
  33.  
  34.  
  35.  
  36.  
  37. }
  38.  
  39.  
  40. int main() {
  41.  
  42.     int times = 0;
  43.  
  44.     int typeLottery = 0;
  45.  
  46.  
  47.     srand(time_t(nullptr));
  48.  
  49.     cout << "Adja meg hanyas lotto (5,6,7)" << endl;
  50.     cin >> typeLottery;
  51.  
  52.     if (typeLottery != 5 && typeLottery != 6 && typeLottery != 7)
  53.     {
  54.         exit(3);
  55.  
  56.     }
  57.     cout << "Adja meg hany mezot szeretne generalni:" << endl;
  58.  
  59.     cin >> times;
  60.  
  61.  
  62.  
  63.     for (int i = 1; i <= times; i++)
  64.     {
  65.  
  66.         switch (typeLottery) {
  67.         case 5:lotteryGen(5, 90); break;
  68.         case 6:lotteryGen(6, 45); break;
  69.         case 7:lotteryGen(7, 35); break;
  70.         default: cout << "Adja meg ujra a kivant tipust"; break;
  71.         }
  72.  
  73.     }
  74.  
  75.     return 0;
  76. }
  77.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement