C语言算弹簧的形变量,09年计算机二级辅导:弹簧单摆的模拟演示代码

实例代码如下:

#include

#include

#include

#include

#include

#define A 480

#define B 120

main()

{

char q;

int gdriver=VGA,gmode=VGAHI;

int i,cl=0,w=1;

float x,y,v1,v2,a1,a2,L,M,m,k,X,X0,F,F1,F2,g,c,s,G,G1,G2;

float sp=2;

initgraph(&gdriver,&gmode,"");

BG: cleardevice();

setcolor(5);

setbkcolor(0);

settextstyle(3,0,4);

outtextxy(80,50,"Single Pendulum Parameters Input");

setcolor(1);

rectangle(70,50,600,90);

setcolor(2);

rectangle(65,45,605,95);

setcolor(14);

rectangle(60,40,610,100);

setcolor(5);

moveto(100,100);

gotoxy(49,12);printf("");

settextstyle(1,0,2);

outtextxy(80,130,"PLEASE INPUT : ( 0

setcolor(15);

line(50,160,620,160);

setcolor(5);

outtextxy(80,170,"The Length Of Pendulum L : ");

scanf("%f",&L);

gotoxy(35,15);printf("");

settextstyle(1,0,2);

outtextxy(80,205,"Elastic Coefficient k : ");

gotoxy(40,14);printf("");

scanf("%f",&k);

outtextxy(80,250,"The Quality Of Spherule M :");

gotoxy(50,17);printf("");

scanf("%f",&M);

outtextxy(80,297,"The Quality Of Pedulum Line m : ");

gotoxy(58,20);printf("");

scanf("%f",&m);

setcolor(15);

line(50,380,620,380);

setcolor(5);

outtextxy(60,400,"Press E to Quit AND Press Any Other Key to Go on");

q=getch();

if(q=='e'||q=='E') goto END;

cleardevice();

GN: setcolor(2);

setbkcolor(0);

g=9.8;G=m*g;x=A+L;y=B;v1=0;v2=0;

settextstyle(1,0,3);

outtextxy(380,20,"Single Pendulum");

settextstyle(1,0,1);

outtextxy(390,60,"(with a spherule)");

settextstyle(1,0,3);

outtextxy(20,40,"S-Pendulum Parameters :");

settextstyle(1,0,1);

moveto(100,90);

gotoxy(29,7);printf("%.1f",L);

outtextxy(30,90,"Length of line L :");

gotoxy(30,9);printf("%.2f",k);

outtextxy(30,123,"P-Coefficient k :");

gotoxy(30,11);printf("%.2f",M);

outtextxy(30,156,"Spherule Quality M :");

gotoxy(30,13);printf("%.2f",m);

outtextxy(30,189,"Line Quality m :");

gotoxy(32,15);printf("%d",w);

outtextxy(30,222,"Control Increment w : ");

settextstyle(2,0,6);

outtextxy(25,290,"Exegesis :");

settextstyle(2,0,4);

outtextxy(30,320," Demo Speed : A -- accelerate , S -- decelerate");

outtextxy(30,340," SP-Length : - -- decrease , + -- increase ");

outtextxy(30,360," Coefficient : < -- decrease , > -- increase ");

outtextxy(30,380," Sph-Quality : Z -- decrease , X -- increase ");

outtextxy(30,400,"Line-Quality : C -- decrease , V -- increase ");

outtextxy(30,420," Increment : Q -- decrease , W -- increase ");

outtextxy(30,440," Press R to Reload AND Press E to Quit");

rectangle(20,285,320,460);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值