Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int rec(int broj) {
- if(broj < 10) {
- return 1;
- }
- int posledna_cifra = broj % 10;
- int pretposledna_cifra = (broj / 10) % 10;
- if(posledna_cifra < pretposledna_cifra) {
- return rec(broj / 10);
- }
- else {
- return 0;
- }
- }
- int main()
- {
- int broj;
- cin >> broj;
- cout << rec(broj) << endl;
- return 0;
- }
- /*
- rec(95431) = rec(9543) = 1
- rec(9543) = rec(954) = 1
- rec(954) = rec(95) = 1
- rec(95) = rec(9) = 1
- rec(9) = 1
- rec(12543) = rec(1254) = 0
- rec(1254) = rec(125) = 0
- rec(125) = 0
- **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement