kolioi

Ticket Combination C++

Sep 9th, 2018
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int comb_num;
  6.     cin >> comb_num;
  7.  
  8.     int comb_count = 0;
  9.     for (char pos1 = 'B'; pos1 <= 'L'; pos1+=2)
  10.     {
  11.         for (char pos2 = 'f'; pos2 >= 'a'; pos2--)
  12.         {
  13.             for (char pos3 = 'A'; pos3 <= 'C'; pos3++)
  14.             {
  15.                 for (int num1 = 1; num1 <= 10; num1++)
  16.                 {
  17.                     for (int num2 = 10; num2 >= 1; num2--)
  18.                     {
  19.                         comb_count++;
  20.                         if (comb_count == comb_num)
  21.                         {
  22.                             cout << "Ticket combination: " << pos1 << pos2 << pos3 << num1 << num2 << endl;
  23.                             int prize = pos1 + pos2 + pos3 + num1 + num2;
  24.                             cout << "Prize: " << prize << " lv.\n";
  25.                             return 0;
  26.                         }
  27.                     }
  28.                 }
  29.             }
  30.         }
  31.     }
  32.  
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment