#include #include using namespace std; int soucet(int a, int b); int asc(char ch); void f(int ll); char cislo[36]; int n, x, i, u, l,max, m; bool plati; int main() { x = 0; max = 0; cislo[0] = 'A'; while (cislo[0] != '#') { x = 0; cin >> cislo; n = strlen(cislo); for (i = 1; i < n; i++) { if (asc(cislo[n-i]) == 0) { continue; } for (m = 0; m <= (n - (2*i)); m++) { f(m); } } if (!(x - 1)) { cout << "The code " << cislo << " is invalid." << endl; } else { cout << "The code " << cislo << " can represent " << x - 1 << " numbers." << endl; } } return 0; } int soucet(int a, int b) { int f; int s = 0; int rad = 1; for (f = b; f > 0; f--) { s = s + asc(cislo[a + f - 1]) * rad; rad *= 10; } return s; } int asc(char ch) { return int(ch) - 48; } void f(int ll) { for (u = 1; u < i + 1; u++) { plati = true; for (l = ll; l < (n - i - u + 1); l++) { if (asc(cislo[l]) == 0) { continue; } if (soucet(l,u) < soucet(n-i,i)) { plati = plati && true; } else { plati = false; } } if (plati) { x += 1; } } return; }