一个编程小问题,求助,拜托,急,在线等,大哥们
#include "stdio.h"int main (void)
{
float gallons;
int miles,i=0;
float x,h,z=0;
printf ("Enter the gallons used (-1 to end): ");
scanf ("%f",&gallons);
printf ("Enter the miles driven: ");
scanf ("%d",&miles);
while ( gallons != -1){
x = miles/gallons;
z += gallons;
i += miles;
printf ("The miles/gallons for this tank was %f\n\n\n",x);
printf ("Enter the gallons used (-1 to end): ");
scanf ("%f",&gallons);
printf ("Enter the miles driven: ");
scanf ("%d",&miles);
}
h = i / z;
printf ("The overall average miles/gallons was %f",h);
return 0;
}
在输入-1时会继续出现"Enter the miles driven: ",怎样才能让程序忽略这个print继续下个语句?各位帮帮忙,谢谢
[[it] 本帖最后由 huangruoxu 于 2008-12-10 11:39 编辑 [/it]]