问题:
解答:
#include <iostream>
using namespace std;
int main()
{
float miles = 0;
float gallons = 0;
float gallon = 0;
cout << "请输入驱车里程(单位为英里):";
cin >> miles;
cout << "请输入使用的汽油量(单位为加仑):";
cin >> gallons;
gallon = miles / gallons;
cout <<"每加仑的里程为:" << gallon << "英里" << endl;
return 0;
}
运行结果:
呵呵,不愿意,就一个小小的除法,竟敢班门弄斧.