1 개요[ | ]
- C++ floor()
C++
CPU
0.4s
MEM
52M
0.4s
Copy
#include <iostream>
#include <cmath>
using namespace std;
int main() {
cout << floor(3.14159) << endl; // 3
cout << floor(-3.14159) << endl; // -4
cout << floor(9.98) << endl; // 9
}
3 -4 9
C++
Copy
#include <iostream>
#include <math.h>
using namespace std;
int main() {
cout << floor(3.14159) << endl; // 3
cout << floor(-3.14159) << endl; // -4
cout << floor(9.98) << endl; // 9
}
Loading
C++
Copy
#include <iostream>
using namespace std;
int main() {
float f = 123.456;
float res = (int)(f*100.0)/100.0;
cout << res << endl; // 123.45
}
Loading