fork download
  1. #include <cmath>
  2. #include <iostream>
  3.  
  4. int main()
  5. {
  6. double f;
  7. while (std::cin >> f) {
  8. f = std::abs(f);
  9. std::cout << (
  10. long(f*10) % 10
  11. + long(f*100) % 10
  12. + long(f*1000) % 10) << '\n';
  13. }
  14. }
Success #stdin #stdout 0s 3472KB
stdin
123.3456
42.4242
-123.3456
-42.4242
105105.9999
-105105.9999
stdout
12
10
12
10
27
27