C language has the following rounding methods: 1. Directly assign values ??to integer variables. For example: int i = 2.5; or i = (int) 2.5; This method uses the decimal part and can be used for your problem. 2. The integer division operator "/" in C/C++ itself has a rounding function (int / int), and the return value of the rounding function introduced below is double. Integer division rounds positive numbers by discarding the decimal part, which can be used in your problem. However, the rounding result of negative numbers in 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. For example: floor(2.5) = 2floor(-2.5) = -34, use the ceil function. ceil(x) returns the smallest integer greater than x. For example: ceil(2.5) = 3ceil(-2.5) = -2floor() is rounding towards negative infinity, floor(-2.5) = -3; ceil() is rounding towards positive infinity, ceil(-2.5) = - 2. The floor function can be used for your problem.
hyh's opinion: int x,a,b,c,d;a=x/1000;b=x%1000/100;