填空题
甲、乙、丙、丁4人同时开始放鞭炮,甲每隔t1秒放一次,乙每隔t2秒放一次,丙每隔t3秒放一次,丁每隔t4秒放一次,每人各放n次。函数fun的功能是根据形参炸响,只算一次响声,第一次响声是在第0秒。
例如,若t1=7,t2=5,t3=6,t4=4,n=10,则总共可听到28次鞭炮声。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
/**********found**********/
#define OK(i, t, n((
1%t==0)&&(i/t<n))
int fun(int t1, int t2, int t3, int t4, int n)
{int count, t, maxt=t1;
if(maxt<t2)maxt=t2;
if(maxt<t3)maxt=t3;
if(maxt<t4)maxt=t4;
count=1; /*给count赋初值*/
/**********found**********/
for(t=1; t<maxt*(n-1);
2)
{
if(OK(t, t1, n)||OK(t, t2, n)||OK(t, t3, n)||OK(t, t4, n))
count++;
}
/**********found**********/
return
3;
}
main()
{int t1=7, t2=5, t3=6, t4=4, n=10, r;
r=fun(t1, t2, t3, t4, n);
printf("The sound:%d/n", r);
}