Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 C++ 编程的新手。我想知道如何输入任何数字(例如 1256 或 2523)并将输出读取为 12.56 或 25.23?
基本上我想要的是最后两位数字出现在小数点的右侧。
float value = input / 100.0f; // C way printf("%.2f\n", value); // C++ way cout << setiosflags(ios::fixed) << setprecision(2) << value << endl;