sum =(n/ 1.0)/p;
Let's do it ~~n/ 1.0. What you get is the operation between floating point number, floating point number and integer, and the compiler will automatically convert it into floating point number for calculation, and you will get the result you want ~