Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cctype>
- using namespace std;
- // PasswordGenerator
- int main()
- {
- int carry = 0;
- int a, b, c, d, e, f, n;
- string s;
- char ch;
- getline(cin, s);
- a = stoi(s);
- getline(cin, s);
- ch = toupper(s[0]);
- b = ch - 'A' + 1;
- getline(cin, s);
- ch = tolower(s[0]);
- c = ch - 'a' + 1;
- cin >> d >> e >> f >> n;
- int f1 = n % f + carry;
- if (f1 == 0)
- {
- f1 = f;
- carry = 0;
- }
- else carry = 1;
- n = n / f;
- if (n == 0)
- {
- cout << "1Aa11" << f1 << endl;
- return 0;
- }
- int e1 = n % e + carry;
- if (e1 == 0)
- {
- e1 = e;
- carry = 0;
- }
- else
- {
- carry = 1;
- }
- n = n / e;
- if (n == 0)
- {
- cout << "1Aa1" << e1 << f1 << endl;
- return 0;
- }
- int d1 = n % d + carry;
- if (d1 == 0)
- {
- d1 = d;
- carry = 0;
- }
- else
- {
- carry = 1;
- }
- n = n / d;
- if (n == 0)
- {
- cout << "1Aa" << d1 << e1 << f1 << endl;
- return 0;
- }
- int c1 = n % c + carry;
- if (c1 == 0)
- {
- c1 = c;
- carry = 0;
- }
- else
- {
- carry = 1;
- }
- n = n / c;
- if (n == 0)
- {
- cout << "1A" << (char)('a' + c1 - 1) << d1 << e1 << f1 << endl;
- return 0;
- }
- int b1 = n % b + carry;
- if (b1 == 0)
- {
- b1 = b;
- carry = 0;
- }
- else
- {
- carry = 1;
- }
- n = n / b;
- if (n == 0)
- {
- cout << "1" << (char)('A' + b1 - 1) << (char)('a' + c1 - 1) << d1 << e1 << f1 << endl;
- return 0;
- }
- if (n > a)
- {
- cout << "No password on this position" << endl;
- return 0;
- }
- if (n == a)
- {
- if (carry == 1)
- {
- cout << "No password on this position" << endl;
- return 0;
- }
- }
- cout << n + carry << (char)('A' + b1 - 1) << (char)('a' + c1 - 1) << d1 << e1 << f1 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement