# include # include # include # include # include # include # include double readdata(FILE* in,double &f) { double r,ro,h,ho,to,so,t,s,v=0,vi,time=-1; int d,I; fscanf(in,"%d",&d); fscanf(in,"%d",&I); fscanf(in,"%lf",&f); if (f==0) return 0; fscanf(in,"%lf %lf",&ho,&ro); for (int i=2;i<=d;i++) { fscanf(in,"%lf %lf",&h,&r); if (h=f)&&(hovi) v-=vi; else if (v>0) { time=v/((3.14159265358979*r*r)*so)+to; v=0; } so=s;to=t; } if((v>0)&&(so>0)) { time=v/((3.14159265358979*r*r)*so)+to; v=0; } return time; } void main() { int nrruns; double time,f; FILE* in=fopen("vase.in","rt"); FILE* out=fopen("vase.out","wt"); fscanf(in,"%d",&nrruns); for (int i=1;i<=nrruns;i++) { time=readdata(in,f); if (time==-1) fprintf (out,"Data Set %d: Vase is never filled to height %.2f\n",i,f); else fprintf (out,"Data Set %d: Vase is filled to height %.2f at time %.2f\n",i,f,time); } }