题解 | #平均年龄#
平均年龄
http://www.nowcoder.com/practice/3745638815d04c26babcfc463c25478c
#include <stdio.h>
#include <math.h>
float getage(int w,float y,double x,int newage)
{
return (1-x)*(y+1)+x*newage;
}
int main()
{
int w,n;
float x,y;
while(scanf("%d %f %f %d",&w,&y,&x,&n)!=EOF){
float answer;
while(n>0)
{
answer=getage(w,y,x,21);
y=answer;
n--;
}
int a=ceil(answer);
printf("%d\n",a);
}
return 0;
}
昆· 希斯莱杰 文章被收录于专栏
学习ing,分享更多优质题解。