#include <cmath>#include <iostream> int main(){ double f; while (std::cin >> f) { f = std::abs(f); std::cout << ( long(f*10) % 10 + long(f*100) % 10 + long(f*1000) % 10) << '\n'; }}
123.3456 42.4242 -123.3456 -42.4242 105105.9999 -105105.9999
12 10 12 10 27 27
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!