今年是1998年,父母年龄(整数)和是78岁,兄弟的年龄和是17岁.四年后(2002年)父的年龄是弟的年龄的4倍,母的年龄是兄的年龄的3倍.那么当父的年龄是兄的年龄的3倍时,是公元哪一年?
#include<stdio.h>
void main()
{int a,b,c,d,s;
do
{
a+b=78,c+d=17;
a++,b++,c++,d++;
}
while((a+4)/(d+4)=4||(b+4)/(c+4)=3);
do
{
for(i=1;i;i++)
}
while((a+i)/(c+i)!=3);
s=1998+i;
printf("the answer is %d/n",s);
}
有一辆货车运输2000只玻璃瓶,运费按到达时完好的瓶子数目计算,每只2角,如有破损,破损瓶子不给运费,还要每只赔偿1元.结果得到运费379.6元,问这次搬运中玻璃瓶破损了几只?
#include<stdio.h>
void main()
{
int a;
do
{
for(a=1;a<=2000;a++);
}
while((2000-a)*0.2-a!=379.6);
printf("the answer is %d/n",a);
}
成功后加分
int main()
{
int father, mother, brother, little_brother;
int find = 0;
int now = 1998;
for(father = 1; !find && father < 78; ++father)
{
mother = 78 - father;
for(little_brother = 0; litter_brother < 17/ 2; ++little_brother)
{
brother = 15 - little_brother;
if((father + 4 ) == 4 * little_brother && (mother + 4) == 3 * brother)
{
find = 1; break;
}
}
}
if(father == 3 * brother)
printf("at the year %d father age is 3 times to brother",%d);
if(father < 3 * brother)
{
for(; father != 3 * brother; now--, father--, brother--) ;
printf("at the year %d father age is 3 times to brother", now);
}
if(father > 3 * brother)
{
for(; father != brother * 3; now++, father++, brother++) ;
printf("at the year %d father age is 3 times to brother", now);
}
return 0;
}
2:
int main()
{
int broken_num = 1;
for(; i < 2000 && 0.2 * (2000 - broken_num) - broken_num != 379.6; ++i )
;
printf("has broken %d bottles on the road\n", broken_num);
return 0;
}