- 论坛徽章:
- 1
|
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main( void )
- {
- // int a, float b;
- // int c; float d;
- // a = 0; b = 3.14;
- // c = 0; d = 3.14;
- // cout << a << " " << b << endl;
- // cout << c << " " << d << endl;
- // return 0;
- float a;
- float f = 4.4f;
- printf("%f %f\n",a,f);
- while (f > 0)
- {
- cin >> a ;
- printf("%f %f\n",a,f);
- f -= a;
- cout << f << endl;
- printf("f = %f\n",f);
- cout<<setiosflags(ios::fixed)<<setprecision(2) <<"cout f = "<< f << endl;
- }
- cin >> a;
- return 0;
-
- }
复制代码 cout的流输出的精度问题
|
|