我的代码有什么问题? 输入以下内容(通过文件)时:
6.02
110 223 144 208 199.5 890
200 69.5 300 138.7 190 601
它会打印ERROR: invalid price in airline # 1
,但不应打印。
这是我的代码。
int fillPricesTable(double flightsPrices[][DEST],int n,double* dollarRate)
{
//n is the number of rows
double Price;
int AirLinesCounter=0;
while (scanf("%lf",dollarRate)==EOF || *dollarRate<=0)
{
errorDollar();
fflush(stdin);
}
for (int i=0;i<n;++i)
{
for (int j=0;j<6;++j)
{
if (scanf("%lf",&Price)==EOF || Price<=0)
{
printf("ERROR: invalid price in airline # %d\n",i);
return -1;
}
flightsPrices[i][j]=Price;
}
AirLinesCounter++;
if(scanf("%lf",&Price)==EOF)
break;
}
return AirLinesCounter;
}