刚学c++ 下面代码不知哪里出了错,连接时出问题,帮忙看下,谢谢
//下面代码不知哪里出了错,连接时出问题
帮忙看下,谢谢
#include<iostream>
using namespace std;
int main()
{
float k=0,j,sum1=0,sum2=0,average=0;
cout<<"Enter the gallons used(-1 to end): ";
cin>>k;
while( k!=-1)
{int t=1;
t++;
if(t>1 )
{
cout<<"Enter the miles drien: ";
cin>>j;
cout<<"The miles/gallons for this tank was "
<<j/k<<endl<<endl;
sum1=sum1+k; //加仑数
sum2=sum2+j; //路程量
}
cout<<"Enter the gallons used(-1 to end): ";
cin>>k;
}
average=sum2/sum1; //平均数
cout<<average;
return 0;
}