Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- for (int i = 9999; i >= 1000; i-- )
- {
- int cifra = i;
- int x = 0;
- int b = 0;
- while (cifra > 0)
- {
- x = cifra % 10;
- cifra = cifra / 10;
- if (x == 0)
- {
- b += 6;
- }
- else if (x == 1)
- {
- b += 3;
- }
- else if (x == 2)
- {
- b += 5;
- }
- else if (x == 3)
- {
- b += 5;
- }
- else if (x == 4)
- {
- b += 4;
- }
- else if (x == 5)
- {
- b += 5;
- }
- else if (x == 6)
- {
- b += 5;
- }
- else if ( x == 7)
- {
- b += 3;
- }
- else if ( x == 8)
- {
- b += 7;
- }
- else if (x == 9)
- {
- b += 5;
- }
- }
- if (b == n)
- {
- cout << i;
- return 0;
- }
- }
- cout << -1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment