C言語でのコーヒーの冷却問題のプログラムについての質問です。以下のプログラムがあるのですが、関数initial内の「tshow」は何を示しており、scanf内で何を渡すのが適切なのでしょうか? #include<stdio.h> #include<math.h> void list(double t,double T_coffee,double T_room){ printf("%6.2f%10.6f%10.6f¥n",t,T_coffee,T_room); return; } void initial(double *t,double *T_init,double *T_room, double *r,double *dt,double *tmax,int *nshow){ double tshow; *t=0.0; *T_init=90;//コーヒー初期温度 *T_room=17;//室温 scanf("%lf %lf %lf %lf",r,dt,tmax,&tshow); //r→冷却定数,dt=刻み幅(=0.1)tmax=1,&tshow= *nshow=tshow / *dt; list(*t,*T_init,*T_room); return; } void euler(double*t,double*T_coffee,double T_room,double r,double dt){ double change; change=-r*(*T_coffee-T_room)*dt; *T_coffee+=change; *t+=dt; return; } main(){ int i,nshow; double t,T_coffee,T_room,r,dt,tmax; initial(&t,&T_coffee,&T_room,&r,&dt,&tmax,&nshow); i=0; while(t<=tmax){ euler(&t,&T_coffee,T_room,r,dt); i++; if(i%nshow==0) list(t,T_coffee,T_room); } }
C言語関連