35 lines
737 B
C++
35 lines
737 B
C++
#include <iostream>
|
|
#include <iomanip>
|
|
#include <cstdio>
|
|
#include <cmath>
|
|
|
|
using namespace std;
|
|
|
|
|
|
int main(int argc, char * argv[]) {
|
|
float a = 12.123456;
|
|
float b = 12.125100;
|
|
|
|
cout << a << " " << b << " " << endl;
|
|
cout << setiosflags(ios::fixed) << setprecision(2) << a << " " << b << " " << endl;
|
|
|
|
printf("%0.2f %0.2f\n", a, b);
|
|
fprintf(stdout, "%0.2f %0.2f\n", a, b);
|
|
fprintf(stderr, "%0.2f %0.2f\n", a, b);
|
|
|
|
double input;
|
|
cin >> input;
|
|
double intpart = 0;
|
|
double fracpart = modf(input, &intpart);
|
|
printf("%f %f\n", intpart, fracpart);
|
|
|
|
if (fracpart == 0.5) {
|
|
cout << "exactly 0.5" << endl;
|
|
}
|
|
else {
|
|
cout << "not exactly 0.5" << endl;
|
|
}
|
|
|
|
return 0;
|
|
}
|