㈠ 编写一个vb模拟斜抛运动的程序 如图
'要求控件两个:
'1-Picture1,2-Text1
'本程序中须在图片框Picture1里用鼠标点击一下即可演示抛物过程,可以向上抛,可以向下抛;
'过程中演示了物体运动轨迹
Option Explicit
Dim V0 As Double, Vx As Double, Vy As Double
Dim s As Single, t As Single
Dim pX As Single, pY As Single
Dim A As Double
Const Pi = 3.1415926
Const g = 9.8
Private Sub Form_Load()
Picture1.AutoRedraw = True
Picture1.Cls
Picture1.DrawWidth = 1
Picture1.Scale (-100, 6000)-(8000, -6000) '自定义坐标系统
Picture1.Line (-100, 0)-(8000, 0), vbGreen
Picture1.Line (0, -6000)-(0, 6000), vbGreen
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error GoTo Err1
'提示:在图片框里点击鼠标开始抛物
If X <= 0 Then Exit Sub
pX = X
pY = Y
A = Atn(Y / X) * 180 / Pi
Picture1.Cls
Picture1.DrawWidth = 1
Picture1.Scale (-100, 6000)-(8000, -6000) '自定义坐标系统
Picture1.Line (-100, 0)-(8000, 0), vbGreen
Picture1.Line (0, -6000)-(0, 6000), vbGreen
V0 = Val(Text1.Text)
Vx = V0 * Cos(A * Pi / 180)
Vy = V0 * Sin(A * Pi / 180)
Timer1.Interval = 10
Timer1.Enabled = True
t = 0
Exit Sub
Err1:
t = 0
Timer1.Enabled = False
End Sub
Private Sub Text1_LostFocus()
Text1.Text = Val(Text1.Text)
End Sub
Private Sub Timer1_Timer()
If t = 0 Then
Picture1.CurrentX = 0
Picture1.CurrentY = 0
End If
t = t + Timer1.Interval / 100
pX = Vx * t
pY = Vy * t - 1 / 2 * g * t ^ 2
Picture1.Line -(pX * 100, pY * 100), vbRed
Picture1.PSet (pX * 100, pY * 100), vbBlack
Picture1.Circle (pX * 100, pY * 100), 50, vbBlack
If pY <= -6000 Or pX >= 8000 Then Timer1.Enabled = False
End Sub
㈡ c语言程序设计题!!!急!!!
1.
#include<stdio.h>
#include<string.h>
int strSearch(char *str[], char *str_sea, int len);
char *str[] = {"abc", "bcd", "xyz", "bcdef", "bcde"};
char *str1 = "bcde";
main()
{
int len = sizeof(str)/sizeof(char *);
printf("%d\n" ,strSearch(str, str1, len));
}
int strSearch(char *str[], char *str_sea, int len)
{
//int len = sizeof(str)/sizeof(char *);
//printf("len: %d \n", len);
int i = 0;
for(i = 0; i < len; i++)
{
if(strcmp(str[i], str_sea) == 0)
{
return 1; }
}
return 0;
}
3.
#include<stdio.h>
#include<math.h>
float func1(float V0, float Q)
{
return 2*9.8*V0*sin(3.14/180*Q);
}
float func2(float V0, float Q)
{
return 9.8*V0*sin(3.14/180*Q);
}
main ()
{
float V0;
float Q;
printf("请输入初速度:");
scanf("%f", &V0);
printf("请输入角度:");
scanf("%f", &Q);
printf("2*Vo*sinQ: %f\n", func1(V0, Q));
printf("请输入初速度:");
scanf("%f", &V0);
printf("请输入角度:");
scanf("%f", &Q);
printf("Vo*sinQ: %f\n", func2(V0, Q));
}
㈢ C语言题:一个质点以初速度V0向上斜抛,与水平夹角为α,求随时间变化,质点的位置(t=0,0.1,0.2,...1s时
因为浮点型的精确程度比较高,一般都有小数点后面6位,如果写成<=1.0,那么有可能1.00023这样的数就排除在条件外了,所以要写成<1.1
㈣ 从A点斜向上抛出一个小球,曲线ABCD是小球运动的一段轨迹.建立如图所示的正交坐标
由题可知,令L=1,设轨迹的方程为f(x)=x*x+b , B的坐标为(0,b),
A(-1,0),C(1,0),D(2,3)
f(1)=f(-1)=1+b=0
f(2)=2*2+b=3
b=-1
则B的坐标为(0,-L)
㈤ 请问斜抛运动x=Vot,y=1/2gt2,y/x=tan怎样联立,谢谢了
你写得不完整。
斜抛运动,水平方向位移 x=v0•t•cosθ,竖直方向位移 y=v0•t•sinθ-(1/2)•gt²
则 y/x=[v0•t•sinθ-(1/2)•gt²]/(v0•t•cosθ)=(v0•t•sinθ)/(v0•t•cosθ)-[(1/2)•gt²]/(v0•t•cosθ)=tanθ-[(1/2)•gt]/(v0•cosθ)
即 y/x=tanθ-[(1/2)•gt]/(v0•cosθ)
将左边分母 x 乘到右边,得 y=xtanθ-x•[(1/2)•gt]/(v0•cosθ)
将 x=v0•t•cosθ 变成 t=x/(v0•cosθ )代入右边第二项 x•[(1/2)•gt]/(v0•cosθ) 得 x•[(1/2)•g•x/(v0•cosθ )]/(v0•cosθ) =gx²/[2(v0•cosθ)²]
最后得到的斜抛运动轨迹方程是 y=xtanθ-gx²/[2(v0•cosθ)²]
㈥ 求时斜抛求抛求时间和路程的c语言编程!知道初速度,和斜抛夹角!大神快帮帮忙!正在做实验
把速度分解了不就可以了吗,也不难。
竖直方向求时间,水平方向求距离。
写代码也简单,几句话就可以了吧。
#defineg9.8//重力加速度
vy=v*sin(theta);//竖直速度
vx=v*cos(theta);//水平速度
t=2*vy/g;//求时间,分两段。上升阶段、下降阶段时间相等。上升阶段是速度减到0
s=vx*t;//水平距离