#include <iostream>
#include <algorithm>
double Sign(double Value){
return Value >= 0 ? 1 : -1;
}
double MakeKasuu(double Value){
double S = Sign(Value);
double Val = std::abs(Value);
while (1 <= Val)Val /= 10;
return Val * S;
}
double MakeJissuu(const double& Value,int N){
int T = 1;
for (int i = 0; i < N; i++){
T *= 10;
}
return Value*T;
}
double MakeHoge(const double& Value,int N){
int Jisuu = static_cast<int>(Value);
double Kasuu = Value - Jisuu;
return MakeKasuu(Jisuu) + MakeJissuu(Kasuu,N);
}
int main(){
double V = 0;
V = 1.23;
std::cout <<V<<" -> "<< MakeHoge(V,2) << std::endl;
V = 20.24;
std::cout <<V<<" -> "<< MakeHoge(V,2) << std::endl;
V = 2.24;
std::cout <<V<<" -> "<< MakeHoge(V,2) << std::endl;
V = 0.01;
std::cout <<V<<" -> "<< MakeHoge(V,2) << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKZG91YmxlIFNpZ24oZG91YmxlIFZhbHVlKXsKCXJldHVybiBWYWx1ZSA+PSAwID8gMSA6IC0xOwp9Cgpkb3VibGUgTWFrZUthc3V1KGRvdWJsZSBWYWx1ZSl7Cglkb3VibGUgUyA9IFNpZ24oVmFsdWUpOwoJZG91YmxlIFZhbCA9IHN0ZDo6YWJzKFZhbHVlKTsKCXdoaWxlICgxIDw9IFZhbClWYWwgLz0gMTA7CglyZXR1cm4gVmFsICogUzsKfQpkb3VibGUgTWFrZUppc3N1dShjb25zdCBkb3VibGUmIFZhbHVlLGludCBOKXsKCWludCBUID0gMTsKCWZvciAoaW50IGkgPSAwOyBpIDwgTjsgaSsrKXsKCQlUICo9IDEwOwoJfQoKCXJldHVybiBWYWx1ZSpUOwp9CmRvdWJsZSBNYWtlSG9nZShjb25zdCBkb3VibGUmIFZhbHVlLGludCBOKXsKCWludCBKaXN1dSA9IHN0YXRpY19jYXN0PGludD4oVmFsdWUpOwoJZG91YmxlIEthc3V1ID0gVmFsdWUgLS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