Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool dobarbroj (int n)
- {
- int a, s=0; bool p;
- a = n;
- p = true;
- while (a>10)
- {
- s = s + a%10;
- if (a/10%10 <= s)
- p = false;
- a = a / 10;
- }
- return p;
- }
- main()
- {
- int n, max = 0;
- while (n!=0)
- {
- cin >> n;
- if ((dobarbroj(n)==true)&&(n>max))
- max = n;
- }
- if (max == 0)
- cout << "Ne postoji takav broj! " << endl;
- else
- cout << max << endl;
- system ("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment