Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to talk about linear table? Integer becomes floating point.
How to talk about linear table? Integer becomes floating point.
There are several rounding methods:

1: Assign directly to integer variables. Such as: inti = 2,5; Or I = (int) 2,5; This method uses the decimal part, which can be used in your question.

2. The integer division operator "/"in C/C++has its own integer function (int/int), and the return value of the integer function described below is double. Integer division is the rounding of positive numbers, which can be used in your problem. However, the rounding result of negative numbers by integer division is related to the C compiler used.

3: Use the floor function. Floor(x) returns the largest integer less than or equal to x.

4: Use the ceil function. Ceil(x) returns the smallest integer greater than x.

5:intb =(int)a; //integer,intc =(int)(a+0.5); //Round off.