<>floor function

Round down .floor(x) Returned is x Integer part of . as ： floor(2.5) = 2 floor(-2.5) = -3

<>ceil function

Round up .ceil(x) Returns the smallest integer greater than or equal to the specified expression . as ： ceil(2.5) = 3 ceil(-2.5) = -2

<>round(x)

return x Rounded integer value of .
C Mathematical functions of language ceil(), floor(), round() #include <math.h> double ceil(double x); double
floor(double x); double round(double x); ceil(x) Return no less than x Minimum integer value of （ Then convert to double type ）.
floor(x) Return no greater than x Maximum integer value of . round(x) return x Rounded integer value of .
<> Example

#include<iostream> #include<cmath> using namespace std; int main() { int t,n,k,
a[4]; while(cin>>t) { while(t--) { scanf("%d%d",&n,&k); a[1]=ceil(n*0.1); a[2]=
ceil(n*0.2); a[3]=ceil(n*0.3); if(k<=a[1]) printf("jin\n"); else if(k>a[1] && k
<=a[1]+a[2]) printf("yin\n"); else if(k>a[1]+a[2] && k<=a[1]+a[2]+a[3]) printf(
"tong\n"); else printf("tie\n"); } } return 0; }

Technology
Daily Recommendation
views 14
views 6
views 6
views 6
views 5