用setprecision即可。如要保留苹果的总价四舍五入后的整数部分:
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
float a, b, total;
cout << "请输入苹果的单价:" << endl;
cin >> a;
cout << "请输入购买苹果的数量:" << endl;
cin >> b;
total = a * b;
cout << "总价的整数部分为:" << int(total) << endl;
cout << "总价四舍五入后的整数部分为:" << setprecision(0) << total << endl;
}