fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int TEN = 10;
  5.  
  6. int main() {
  7. int n;
  8. cin >> n;
  9. int countDigits = 1, nCpy = n;
  10. while (nCpy >= TEN) {
  11. nCpy /= TEN;
  12. }
  13. while (n > TEN) {
  14. if (n % TEN == nCpy) {
  15. ++countDigits;
  16. }
  17. n /= TEN;
  18. }
  19. cout << countDigits;
  20. return 0;
  21. }
Success #stdin #stdout 0s 5284KB
stdin
1000000000 -> 1
 2542322 -> 4
 555555555 -> 9

2423252 -> 4

325311 -> 2   
6668-> 3  
12311518 -> 4

6544236 - > 2      141131 - > 4    333 -> 3

101 --> 2 / 29 --> 1 / 101010 ---> 3
stdout
1