编程弹个球
❶ vf编程:一个球从100米高度自由落下,每次落地后反弹回原高度的一半;再落下,求它在第10次落地时
h=100
s=100
for n=1 to 10
h=h/2
s=s+h
endfor
?"在第10次落地时,共经过米数:",s-h
?"第10次反弹高度米数:",h
❷ 编程三球运动怎么做
刚才的话我说刚才我讲的话因为我说想要变成删除运动的东西的话大家可以直接从特大方
❸ 如何实现AS3.0编程中小球跳跃求完整代码~
舞台上放个小球,实例名mc,第一帧输代码
varg:Number=0.5;//重力加速度
vardg:Number=0.7;//反弹的衰减值,如果是1不会衰减,小球会一直弹跳,小于1的时候每次弹跳会衰减
vardx:Number=0.99;//水平方向衰减值,同上
varsw:Number=stage.stageWidth;
varsh:Number=stage.stageHeight;
mc.vy=0;//小球垂直方向的速度
mc.vx=28;//小球水平方向的速度,不需要水平运动设为0就行
//用ENTER_FRAME驱动小球运动
mc.addEventListener(Event.ENTER_FRAME,onEnter);
functiononEnter(evt:Event):void{
//竖直方向的运动
evt.target.vy+=g;
evt.target.y+=evt.target.vy;
//水平方向的运动
evt.target.x+=evt.target.vx;
evt.target.vx*=dx;
//判断水平方向是否碰到边界
if(evt.target.x>=sw-evt.target.width/2||evt.target.x<=evt.target.width/2){
evt.target.vx*=-1;
}
//如果水平方向运动值已经衰减的非常小,则判断水平方向运动已经停止
if(Math.abs(evt.target.vx)<1){
evt.target.vx=0;
}
//判断竖直方向是否碰到地面
if(evt.target.y>=sh-evt.target.height/2){
evt.target.y=sh-mc.height/2;
evt.target.vy*=dg*-1;
//如果竖直方向运动值已经衰减的非常小,则判断竖直方向运动已经停止
if(Math.abs(evt.target.vy)<0.5){
evt.target.vy=0;
evt.target.y=sh-mc.height/2;
}
}
//如果水平方向和竖直方向速度都为0,运动完毕,停止侦听
if(evt.target.vx==0&&evt.target.y==0){
evt.target.removeEventListener(Event.ENTER_FRAME,onEnter);
}
}
❹ c语言编写程序解决小球下落反弹问题用
#include <stdio.h>
main()
{
float sum=0;
int i=0;
float height=100;
sum+=height;
while(i<10)
{
height=height/2;
sum+=2*height;
i++;
}
printf("总长度:%f 第10次跳%f米",sum,height);
}
❺ 模拟一个小球在屏幕上匀速直线运动,当小球碰到屏幕第四个边时便会弹回,用QBASIC怎么编程序
首先创建一个不规则形状的窗口,网上很多例子.
然后声明2个整数变量CX,CY和两个Boolean 变量ToLeft,ToTop
窗口上添加一个Timer控见.
添加如下代码:
Private sub Timer1_timer()
if cx<=0 Then
toleft=true
else
toleft=false
end if
if cy<=0 then
totop=false
else
totop=true
end if
if toleft then
cx=cx-10
else
cx=cx+10
end if
if totop then
cy=cy-10
else
cy=cy+10
end if
move cx,cy
end sub
❻ c语言,一个球从某高度h落下,每次落地后反弹回原来高度的一半,再落下。编程计算球在10次落地
根据你的题目和输出样式截图分析:
1、每次输出当前坠落的高度,及球本次坠落后经过的距离总和。
2、输出包含小数,因此高度及距离变量采用浮点数。
3、递归/循环只执行10次。
3、看你图上,输出浮点数小数不显示多余的0,因此打印格式要用%g而不是%f(最多保留6位)。
#include <stdio.h>
void drop(float height);
int main()
{
float height;
printf("初始高度:");
scanf("%f",&height);
drop(height);
return 0;
}
void drop(float height)
{
static int cnt=1;
static float distance=0;//每次坠落后球移动的距离总和
if(height>0){
distance+=height;
printf("第%d次高度%g ",cnt,height);
printf("第%d次距离%g ",cnt,distance);
if(cnt<10)
cnt++,distance+=height/2,drop(height/2);
else
cnt=1,distance=0;
}
}
❼ 通过VB编写程序,单击开始,实现一个小球从高处落下,碰到地面后弹起到原来高度的一半,再次落下......
Dim h As Integer, h0 As Integer, d As Integer, n As Integer
Private Sub Command1_Click()
Timer1.Enabled = True
Command1.Enabled = False
End Sub
Private Sub Form_Load()
Shape1.Shape = 3
Shape1.FillStyle = 0
Shape1.FillColor = vbYellow
d = 1
Timer1.Interval = 50
Timer1.Enabled = False
h = Shape1.Top
h0 = h
End Sub
Private Sub Timer1_Timer()
If d = 1 Then
If Shape1.Top < Form1.Height - 1500 Then
Shape1.Top = Shape1.Top + 50
Else
d = 0
h = Form1.Height - 1500 - (Form1.Height - 1500 - h) / 2
End If
Else
If Shape1.Top > h Then
Shape1.Top = Shape1.Top - 50
Else
d = 1
n = n + 1
If n > 10 Then Timer1.Enabled = False
End If
End If
End Sub
❽ java编程一个球从100米处落下,反弹回原来高度的一半,行程200米反弹多少次
写了个小程序试了下,如果不取精确到某位的近似值的话,估计应该是个无限循环吧。这个题挺有意思,期待高手指教。 import java.math.BigDecimal; public class fantan200m { public static void main(String[] args){ BigDecimal total=new BigDecimal(200); BigDecimal journeyInit=new BigDecimal(100); BigDecimal journey=new BigDecimal(100); BigDecimal divisor=new BigDecimal(2); int count=0; while(true){ if(journey==total |count==2000){ System.out.println("finish!"); System.out.println("total count="+count); break; }else{ count++; BigDecimal fantan=journeyInit.divide(divisor); journeyInit=fantan; journey=journey.add(fantan); System.out.println("journey."+count+"="+journey); } } } }
❾ java编程一个球从100米高度落下,每次反弹回原来高度的一半,行程200米反弹多少次
设球目前高度是x;
x1=100;
球掉下去,反弹一次,高度变为x2=x1/2;
设行程为s。刚开始s=0;反弹一次s=x1+x2;
具体代码大致如下:
int x1,x2,n;
x1=100;
do while(s<=200){
x2=x1/2;
s=x1+x2;
x1=x2;‘’每弹一次,目前高度x1就变成x2了。
n+n++;‘’用来统计弹了多少次
}
System.out.println("共弹了"+n+"次");
鄙人愚见,您参考参考。
❿ 程序设计绘制一个自由落体后反弹的皮球
您好,1、同一个皮球,从不同的高度让其自由落体,起始高度越高,反弹高度越高。
2、同一个皮球,每次放出一些气,从相同的高度让其自由落体,气越足,反弹高度越高。
3、同一个皮球,每次使用不同密度的气体将其充满,从相同的高度让其自由落体,气体密度越低,反弹高度越高。
4、不同材质同样大小的皮球,充满同样的气体,从相同的高度让其自由落体,发现材质不同,反弹高度也不同。
5、相同材质不同大小的皮球,充满同样的气体,从相同的高度让其自由落体,发现大小不同,反弹高度也不同。