[求助]四舍五入2位之迷惑
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
double x;
cin>>x;
x+=0.005;cout<<x<<endl;
double y=(int)(x*100);
cout<<y<<endl;
x=(double)(y/100);
cout<<x;
system("PAUSE");
return EXIT_SUCCESS;
}
你输入3.145试试
X明明变了,那里为什么又回去了