谁能告诉我怎么检查我从a* b那里得到的号码?也就是说,我想知道这个数字的每个部分,例如,如果这个表达式的结果是25,我想知道第一个数字是2,第二个数字是5。
发布于 2010-05-14 17:28:06
也许有点过火了..。但即使是替身也能用
#include <sstream>
#include <iostream>
int main()
{
double a = 5.2;
double b = 7;
double z = a*b;
std::stringstream s;
s << z;
for (int i = 0; i < s.str().length(); i++)
std::cout << i << ": " << s.str()[i] << std::endl;
return 0;
}https://stackoverflow.com/questions/2833011
复制相似问题