这是《C Primer Plus》第四章编程练习(第六版)4.8.5的练习题:
参考代码如下:
#include
int main(void){
float downloadSpeed,fileSize;
printf("Please input your download speed(Mb/s):");
scanf("%f",&downloadSpeed);
printf("Please input you file size(Mb):");
scanf("%f",&fileSize);
printf("At %.2f megabits per second, a file of %.2f megabytes\n",downloadSpeed,fileSize);
printf("download in %.2f seconds.\n",fileSize*8/downloadSpeed);
}
执行结果如下: