fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int TEN = 10;
  5.  
  6. int main() {
  7. int n, dif, max= 0,dif2, cnt = 1;
  8. cin >> n;
  9. dif = n % TEN- n / TEN % TEN;
  10. if (dif < 0) {
  11. dif *= -1;
  12. }
  13. while (n >=100) {
  14. dif2 = n / 10 % 10- n /100 % 10;
  15. if ( dif2 < 0) {
  16. dif2 *=-1;
  17. }
  18. if ( dif == dif2) {
  19. ++cnt;
  20. }
  21. if ( dif2 > dif) {
  22. dif = dif2;
  23. cnt = 1;
  24. }
  25. n /= 10;
  26. }
  27. cout <<dif << " " << cnt;
  28. return 0;
  29. }
Success #stdin #stdout 0s 5316KB
stdin
191
stdout
8 2