编写程序:迅速运动速度为10,加速度为2,求运动20秒后的速度和路程及平均速度
根据公式写就行s = v0t + at²/2
#include<stdio.h>
int main(){
int v1=10,a=2,v2,s,ave;
v2=v1+a*20;
s=v1*20 + a*20*20/2;
printf("20秒后的速度:%d\n,路程:%d\n平均速度:%d",v2,s,(v2+v1)/2);
return 0;
}
#include <stdio.h>
int main(int argc, char const *argv[])
{
int speed = 10;
int acc = 2;
int time = 20;
printf("%d\n", speed + acc * time);
printf("%d\n", (speed + speed + acc * time) * time / 2);
printf("%f\n", ((speed + speed + acc * time) * time / 2) / (float)time);
return 0;
}