Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int z, c;
- cin >> z >> c;
- int najmal, najgolem;
- najmal = 1;
- for(int i = 0; i < c-1; i++)
- {
- najmal *= 10;
- }
- najgolem = (najmal * 10) - 1;
- int broj;
- int zbir;
- for(int i = najmal; i < najgolem; i++)
- {
- broj = i;
- zbir = 0;
- while(broj > 0)
- {
- zbir += broj;
- broj /= 10;
- }
- if(z == zbir)
- {
- cout << i << endl;
- return 0;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement