求一简单的C语言动画程序。

 我来答
a1012144015
2016-01-02 · TA获得超过6415个赞
知道大有可为答主
回答量:9038
采纳率:40%
帮助的人:1348万
展开全部
C语言动画程序
#include <math.h>
#include <stdio.h>
#include <graphics.h>
#include <dos.h>

#define pi 3.1415926535

double ca3mm1(double m1,double m2);
double ca3fm1(double cosine,double sine);
double ca5fm2(double a6m,double a5m,double a4m,double a4f,int shang);
double ca6fm2(double a4m ,double a4f,double a5m , double a5f);
char inbox(int x,int y,int x1,int y1);
char buf();

main()
{
double m=3.0;
double xo=100.0,yo=200.0,a1=30.0,t1=pi;
double xc=xo+m*a1,yc=yo;
double a2=8.0,a3,a4=25.0,a5=30.0,a6=20.0,a7=35.0;
double t2,t3,t4,t5,t6,t7;
double xo1=xo+m*150,yo1=yo;
double xc1=xo1-m*a1,yc1=yo1;
double i,j,k;
double l1;
double n=116.1,nt;
initscreen();

setfillstyle(SOLID_FILL,DARKGRAY);
bar(0,0,640,480);
mybutton(10,10,"BEGIN",1,0);
mybutton(500,10,"EXIT",1,0);
line(0,69,640,69);
mouseinit();
changemousecross();
setmousexy(320,20);
mouseshow();
setmousearea(0,0,640,60);
do{
if(inbox(10,10,70,26)&&button()==1)
{mousehide(); mybutton(10,10,"BEGIN",0,0); mouseshow(); mousehold(); mousehide(); mybutton(10,10,"BEGIN",1,7); mouseshow(); break; }
if(inbox(500,10,555,26)&&button()==1)
{mousehide(); mybutton(500,10,"EXIT",0,0); mouseshow(); mousehold(); mousehide(); mybutton(500,10,"EXIT",1,7); mouseshow(); exit(0); }
if(buf()==56)
for(i=0;i<10000;i++){
switch (buf()){
case 18:{
mousehide();
mybutton(500,10,"EXIT",0,0);
mouseshow();
delay(4000);
mousehide();
mybutton(500,10,"EXIT",1,7);
mouseshow();
exit(0);
}
case 48: {
mousehide();
mybutton(10,10,"BEGIN",0,0);
mouseshow();
delay(4000);
mousehide();
mybutton(10,10,"BEGIN",1,7);
mouseshow();
goto run;
}
default:break;
}
}
}while(1);
run:
drawjijia(xo,yo,1);
drawjijia(xc,yc,1);
drawjijia(xo1,yo1,1);
drawjijia(xc1,yc1,1);
setwritemode(1);
do{
for(i=0;i<360.0;i+=1.0)
{
t2=i;
a3=ca3mm1(a1*cos(t1)+a2*cos(t2*pi/180.0),a1*sin(t1)+a2*sin(t2*pi/180.0));
t3=ca3fm1(a1*cos(t1)+a2*cos(t2*pi/180.0),a1*sin(t1)+a2*sin(t2*pi/180.0));
a4=a3;
t4=t3;
t5=ca5fm2(a6,a5,a4,t4,0);
t6=ca6fm2(a4,t4,a5,t5);
t7=t6-90.0;
l1=xc1-xc-2*m*a7*cos(t7*pi/180);
nt=(asin(l1/2/(n/2))*180/pi)-90.0;
drawline(xo,yo,a2,t2,m,LIGHTGRAY);
drawline(xo+m*a2*cos(t2*pi/180),yo-m*a2*sin(t2*pi/180),a5,t5,m,LIGHTGRAY);
drawline(xc,yc,a6,t6,m,LIGHTGRAY);
drawline(xc,yc,a7,t7,m,LIGHTGRAY);
drawline1(xo1,yo1,a2,t2,m,LIGHTGRAY);
drawline1(xo1+m*a2*cos((180-t2)*pi/180),yo1-m*a2*sin((180-t2)*pi/180),a5,t5,m,LIGHTGRAY);
drawline1(xc1,yc1,a6,t6,m,LIGHTGRAY);
drawline1(xc1,yc1,a7,t7,m,LIGHTGRAY);
for(j=-1;j<20;j++)
{ drawline(xc+m*a7*cos(t7*pi/180),(yc-m*a7*sin(t7*pi/180)-j*n*sin(nt*pi/180)),n,nt,1.0,GREEN);
drawline1(xc1-m*a7*cos(t7*pi/180),(yc1-m*a7*sin(t7*pi/180)-j*n*sin(nt*pi/180)),n,nt,1.0,DARKGRAY);
}
delay(300);
drawline(xo,yo,a2,t2,m,LIGHTGRAY);
drawline(xo+m*a2*cos(t2*pi/180.0),yo-m*a2*sin(t2*pi/180.0),a5,t5,m,LIGHTGRAY);
drawline(xc,yc,a6,t6,m,LIGHTGRAY);
drawline(xc,yc,a7,t7,m,LIGHTGRAY);
drawline1(xo1,yo1,a2,t2,m,LIGHTGRAY);
drawline1(xo1+m*a2*cos((180-t2)*pi/180),yo1-m*a2*sin((180-t2)*pi/180),a5,t5,m,LIGHTGRAY);
drawline1(xc1,yc1,a6,t6,m,LIGHTGRAY);
drawline1(xc1,yc1,a7,t7,m,LIGHTGRAY);
for(j=-1;j<20;j++)
{ drawline(xc+m*a7*cos(t7*pi/180),(yc-m*a7*sin(t7*pi/180)-j*n*sin(nt*pi/180)),n,nt,1.0,GREEN);
drawline1(xc1-m*a7*cos(t7*pi/180),(yc1-m*a7*sin(t7*pi/180)-j*n*sin(nt*pi/180)),n,nt,1.0,DARKGRAY);
}
setwritemode(0);
if(inbox(500,10,555,26)&&button()==1)
{mousehide(); mybutton(500,10,"EXIT",0,0); mouseshow(); mousehold(); mousehide(); mybutton(500,10,"EXIT",1,7); mouseshow(); exit(0); }
if(buf()==56)
for(k=0;k<10000;k++){
switch (buf()){
case 18:{
mousehide();
mybutton(500,10,"EXIT",0,0);
mouseshow();
delay(4000);
mousehide();
mybutton(500,10,"EXIT",1,7);
mouseshow();
exit(0); }
default:break;
}
}
setwritemode(1);
}
}while(1);
}

drawline(double xo,double yo,double mo,double fujiao,double m,int color)
{
double x,y;
x=(xo+m*mo*cos(fujiao*pi/180));
y=(yo-m*mo*sin(fujiao*pi/180));
setcolor(color);
line (xo,yo,x,y);
}
drawline1(double xo,double yo,double mo,double fujiao,double m,int color)
{
double x,y;
x=(xo-m*mo*cos(fujiao*pi/180));
y=(yo-m*mo*sin(fujiao*pi/180));
setcolor(color);
line (xo,yo,x,y);
}
drawjijia(double x,double y,int shang)
{
setcolor(RED);
if (shang==1){
circle(x,y,3);
line(x-3.0,y+3.0,x-15.0,y+20.0);
moveto(x-15,(int)(y+20));
lineto((int)(x+15),(int)(y+20));
moveto((int)(x+15),(int)(y+20));
lineto(x+3,y+3);}
setcolor(RED);
if (shang==0){
circle((int)x,(int)y,3);
line (x-3,y-3,x-15,y-20);
moveto(x-15,y-20);
lineto(x+15,y-20);
moveto(x+15,y-20);
lineto(x+3,y-3);
}
}
double ca3mm1(double m1,double m2)
{
double temp;
temp = sqrt(m1*m1 + m2*m2);
return(temp);
}
double ca3fm1(double cosine,double sine)
{
float temp;
if (sine > 0 && cosine > 0)
temp = atan(sine / cosine) * 180 / pi;
if (sine > 0 && cosine < 0)
temp = (atan(sine / cosine) + pi) * 180 / pi;
if (sine < 0 && cosine < 0)
temp = (atan(sine / cosine) + pi) * 180 / pi;
if (sine < 0 && cosine > 0)
temp = (atan(sine / cosine) + 2 * pi) * 180 / pi;
return(temp);
}
double ca5fm2(double a6m,double a5m,double a4m,double a4f,int shang)
{
double temp,sine1,cosine1;
cosine1 = (a6m *a6m - a4m *a4m - a5m*a5m) / (2 * a4m * a5m);
sine1 = sqrt(1 - cosine1 *cosine1);
if (shang==0)
sine1 = sine1*(-1);
if (sine1 > 0 && cosine1 > 0)
temp = a4f + (atan(sine1 / cosine1) * 180 / pi);
if (sine1 > 0 && cosine1 < 0)
temp = a4f + ((atan(sine1 / cosine1) + pi) * 180 / pi);
if (sine1 < 0 && cosine1 < 0)
temp = a4f + ((atan(sine1 / cosine1) + pi) * 180 / pi);
if (sine1 < 0 && cosine1 > 0)
temp = a4f + ((atan(sine1 / cosine1) + 2 * pi) * 180 / pi);
return(temp);
}
double ca6fm2(double a4m ,double a4f,double a5m , double a5f)
{
double temp,sine1,cosine1;
sine1 = a4m * sin(a4f * pi / 180) + a5m * sin(a5f * pi / 180);
cosine1 = a4m * cos(a4f * pi / 180) + a5m * cos(a5f * pi / 180);

if (sine1 > 0 && cosine1 > 0)
temp = (atan(sine1 / cosine1) * 180 / pi);
if (sine1 > 0 && cosine1 < 0)
temp = ((atan(sine1 / cosine1) + pi) * 180 / pi);
if (sine1 < 0 && cosine1 < 0)
temp = ((atan(sine1 / cosine1) + pi) * 180 / pi);
if (sine1 < 0 && cosine1 > 0)
temp = ((atan(sine1 / cosine1) + 2 * pi) * 180 / pi);
return(temp);
}
initscreen()
{
int gd=DETECT,gm;
registerbgidriver(EGAVGA_driver);
initgraph(&gd,&gm,"");
}
博思aippt
2024-07-20 广告
博思AIPPT是基于ai制作PPT的智能在线工具,它提供了4种AI制作PPT的方式,包括AI生成大纲、AI直接生成PPT、文本生成PPT、AI提炼文档生成PPT,一站式集成多种AI生成PPT的方式,可满足办公用户的不同需求和使用场景。ai生... 点击进入详情页
本回答由博思aippt提供
jjshouji
2012-03-09 · TA获得超过333个赞
知道答主
回答量:153
采纳率:100%
帮助的人:40.6万
展开全部
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<conio.h>

typedef struct snake
{
int a;
int b;
struct snake *u;
struct snake *n;
}snake,*snake1;
typedef struct food
{
int a;
int b;
}food;
void main()
{
char c,c0 = 'd';
int i,j,k,n=1,t,at;
snake p,q;
snake *dd,*dd0,*dd1,*dd2;
food f;
srand(time(NULL));
p.u = NULL;
p.n = &q;
p.a = 5;p.b = 6;q.a = 5;q.b = 5;
q.u = &p;q.n = NULL;
dd=dd2= &q;
f.a=(rand()%15+1);
f.b=(rand()%15+1);
while(1)
{
srand(time(NULL));
system("cls");
for(i = 0;i < 17;i ++)
{
for(j = 0; j < 17;j++)
{

if(i == 0 )
printf("▁");
else if(i == 16)
printf("▔");
else if(j == 0)
printf("▕");
else if(j == 16)
printf("▏");
else if(i == p.a && j == p.b)
printf("■");
else if(i == f.a && j == f.b)
printf("★");
else
{
t = 0;
dd = dd2;
for(k = 0; k < n ;k++)
{
if(i == dd->a && j == dd->b)
{
printf("□");
t = 1;
break;
}

dd = dd->u;
}
if(t == 0)
printf(" ");
}

}printf("\n");
}
at = 0;
dd =dd2;
for(i=0;i<n;i++)
{
if(p.a == dd->a && p.b == dd->b)
{
printf("game over!!\n");
exit(0);
}
dd = dd->u;
}
if(p.a == f.a && p.b == f.b)
{
dd = dd2;
at =1;
f.a = (rand()%15+1);
f.b = (rand()%15+1);
for(i=0;i<n;i++)
{
if(f.a == dd->a && f.b == dd->b)
{
f.a = dd2->a;
f.b = dd2->b;
break;
}
}
n++;
}
if(kbhit())
{
c = getch();
dd = dd2;
if(c == 'w' && c0 != 's')
{
if(at == 1)
{
dd0 =(snake1)malloc(sizeof(snake));
dd0->a = dd2->a;dd0->b = dd2->b;
dd0->n = NULL;dd0->u = dd2;
dd2=dd0;
}
dd = dd2;
for(i = 0; i<n ; i++)
{
dd1 = dd->u;
dd->b = dd1->b;
dd->a = dd1->a;
dd = dd->u;
}
if(p.a == 1)
p.a = 15;
else
p.a = (p.a-1)%15;
}
else if(c == 's' && c0 != 'w')
{
if(at == 1)
{
dd0 =(snake1)malloc(sizeof(snake));
dd0->a = dd2->a;dd0->b = dd2->b;
dd0->n = NULL;dd0->u = dd2;
dd2=dd0;
}
dd = dd2;
for(i = 0; i<n ; i++)
{
dd1 = dd->u;
dd->b = dd1->b;
dd->a = dd1->a;
dd = dd->u;
}
p.a = (p.a%15)+1;
}
else if(c == 'a' && c0 != 'd')
{
if(at == 1)
{
dd0 =(snake1)malloc(sizeof(snake));
dd0->a = dd2->a;dd0->b = dd2->b;
dd0->n = NULL;dd0->u = dd2;
dd2=dd0;
}
dd = dd2;
for(i = 0; i<n ; i++)
{
dd1 = dd->u;
dd->b = dd1->b;
dd->a = dd1->a;
dd = dd->u;
}
if(p.b == 1)
p.b = 15;
else
p.b = (p.b-1)%15;
}
else if(c == 'd' && c0 != 'a')
{
if(at == 1)
{
dd0 =(snake1)malloc(sizeof(snake));
dd0->a = dd2->a;dd0->b = dd2->b;
dd0->n = NULL;dd0->u = dd2;
dd2=dd0;
}
dd = dd2;
for(i = 0; i<n ; i++)
{
dd1 = dd->u;
dd->b = dd1->b;
dd->a = dd1->a;
dd = dd->u;
}
p.b = (p.b%15)+1;
}
else
{
goto qq;
}
c0 = c;
}
else
{
qq: if(c0 == 'w')
{
if(at == 1)
{
dd0 =(snake1)malloc(sizeof(snake));
dd0->a = dd2->a;dd0->b = dd2->b;
dd0->n = NULL;dd0->u = dd2;
dd2=dd0;
}
dd = dd2;
for(i = 0; i<n ; i++)
{
dd1 = dd->u;
dd->b = dd1->b;
dd->a = dd1->a;
dd = dd->u;
}
if(p.a == 1)
p.a = 15;
else
p.a=(p.a-1)%15;
}
else if(c0 == 's')
{
if(at == 1)
{
dd0 =(snake1)malloc(sizeof(snake));
dd0->a = dd2->a;dd0->b = dd2->b;
dd0->n = NULL;dd0->u = dd2;
dd2=dd0;
}
dd = dd2;
for(i = 0; i<n ; i++)
{
dd1 = dd->u;
dd->b = dd1->b;
dd->a = dd1->a;
dd = dd->u;
}
p.a=(p.a%15)+1;
}
else if(c0 == 'a')
{

if(at == 1)
{
dd0 =(snake1)malloc(sizeof(snake));
dd0->a = dd2->a;dd0->b = dd2->b;
dd0->n = NULL;dd0->u = dd2;
dd2=dd0;
}
dd = dd2;
for(i = 0; i<n ; i++)
{
dd1 = dd->u;
dd->b = dd1->b;
dd->a = dd1->a;
dd = dd->u;
}
if(p.b == 1)
p.b = 15;
else
p.b=(p.b-1)%15;
}
else if(c0 == 'd')
{
if(at == 1)
{
dd0 =(snake1)malloc(sizeof(snake));
dd0->a = dd2->a;dd0->b = dd2->b;
dd0->n = NULL;dd0->u = dd2;
dd2=dd0;
}
dd = dd2;
for(i = 0; i<n ; i++)
{
dd1 = dd->u;
dd->b = dd1->b;
dd->a = dd1->a;
dd = dd->u;
}
p.b=(p.b%15)+1;

}
}
fflush(stdin);
dd = &q;
_sleep(200);
}
}
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
水寒三尺
2008-01-10 · TA获得超过246个赞
知道答主
回答量:116
采纳率:0%
帮助的人:0
展开全部
#include <math.h>
#include <stdio.h>
#include <graphics.h>
#include <dos.h>

#define pi 3.1415926535

double ca3mm1(double m1,double m2);
double ca3fm1(double cosine,double sine);
double ca5fm2(double a6m,double a5m,double a4m,double a4f,int shang);
double ca6fm2(double a4m ,double a4f,double a5m , double a5f);
char inbox(int x,int y,int x1,int y1);
char buf();

main()
{
double m=3.0;
double xo=100.0,yo=200.0,a1=30.0,t1=pi;
double xc=xo+m*a1,yc=yo;
double a2=8.0,a3,a4=25.0,a5=30.0,a6=20.0,a7=35.0;
double t2,t3,t4,t5,t6,t7;
double xo1=xo+m*150,yo1=yo;
double xc1=xo1-m*a1,yc1=yo1;
double i,j,k;
double l1;
double n=116.1,nt;
initscreen();

setfillstyle(SOLID_FILL,DARKGRAY);
bar(0,0,640,480);
mybutton(10,10,"BEGIN",1,0);
mybutton(500,10,"EXIT",1,0);
line(0,69,640,69);
mouseinit();
changemousecross();
setmousexy(320,20);
mouseshow();
setmousearea(0,0,640,60);
do{
if(inbox(10,10,70,26)&&button()==1)
{mousehide();
mybutton(10,10,"BEGIN",0,0);
mouseshow();
mousehold();
mousehide();
mybutton(10,10,"BEGIN",1,7);
mouseshow();
break;
}
if(inbox(500,10,555,26)&&button()==1)
{mousehide();
mybutton(500,10,"EXIT",0,0);
mouseshow();
mousehold();
mousehide();
mybutton(500,10,"EXIT",1,7);
mouseshow();
exit(0);
}
if(buf()==56)
for(i=0;i<10000;i++){
switch (buf()){
case 18:{
mousehide();
mybutton(500,10,"EXIT",0,0);
mouseshow();
delay(4000);
mousehide();
mybutton(500,10,"EXIT",1,7);
mouseshow();
exit(0);
}
case 48: {
mousehide();
mybutton(10,10,"BEGIN",0,0);
mouseshow();
delay(4000);
mousehide();
mybutton(10,10,"BEGIN",1,7);
mouseshow();
goto run;
}
default:break;
}
}
}while(1);
run:
drawjijia(xo,yo,1);
drawjijia(xc,yc,1);
drawjijia(xo1,yo1,1);
drawjijia(xc1,yc1,1);
setwritemode(1);
do{
for(i=0;i<360.0;i+=1.0)
{
t2=i;
a3=ca3mm1(a1*cos(t1)+a2*cos(t2*pi/180.0),a1*sin(t1)+a2*sin(t2*pi/180.0));
t3=ca3fm1(a1*cos(t1)+a2*cos(t2*pi/180.0),a1*sin(t1)+a2*sin(t2*pi/180.0));
a4=a3;
t4=t3;
t5=ca5fm2(a6,a5,a4,t4,0);
t6=ca6fm2(a4,t4,a5,t5);
t7=t6-90.0;
l1=xc1-xc-2*m*a7*cos(t7*pi/180);
nt=(asin(l1/2/(n/2))*180/pi)-90.0;
drawline(xo,yo,a2,t2,m,LIGHTGRAY);
drawline(xo+m*a2*cos(t2*pi/180),yo-m*a2*sin(t2*pi/180),a5,t5,m,LIGHTGRAY);
drawline(xc,yc,a6,t6,m,LIGHTGRAY);
drawline(xc,yc,a7,t7,m,LIGHTGRAY);
drawline1(xo1,yo1,a2,t2,m,LIGHTGRAY);
drawline1(xo1+m*a2*cos((180-t2)*pi/180),yo1-m*a2*sin((180-t2)*pi/180),a5,t5,m,LIGHTGRAY);
drawline1(xc1,yc1,a6,t6,m,LIGHTGRAY);
drawline1(xc1,yc1,a7,t7,m,LIGHTGRAY);
for(j=-1;j<20;j++)
{ drawline(xc+m*a7*cos(t7*pi/180),(yc-m*a7*sin(t7*pi/180)-j*n*sin(nt*pi/180)),n,nt,1.0,GREEN);
drawline1(xc1-m*a7*cos(t7*pi/180),(yc1-m*a7*sin(t7*pi/180)-j*n*sin(nt*pi/180)),n,nt,1.0,DARKGRAY);
}
delay(300);
drawline(xo,yo,a2,t2,m,LIGHTGRAY);
drawline(xo+m*a2*cos(t2*pi/180.0),yo-m*a2*sin(t2*pi/180.0),a5,t5,m,LIGHTGRAY);
drawline(xc,yc,a6,t6,m,LIGHTGRAY);
drawline(xc,yc,a7,t7,m,LIGHTGRAY);
drawline1(xo1,yo1,a2,t2,m,LIGHTGRAY);
drawline1(xo1+m*a2*cos((180-t2)*pi/180),yo1-m*a2*sin((180-t2)*pi/180),a5,t5,m,LIGHTGRAY);
drawline1(xc1,yc1,a6,t6,m,LIGHTGRAY);
drawline1(xc1,yc1,a7,t7,m,LIGHTGRAY);
for(j=-1;j<20;j++)
{ drawline(xc+m*a7*cos(t7*pi/180),(yc-m*a7*sin(t7*pi/180)-j*n*sin(nt*pi/180)),n,nt,1.0,GREEN);
drawline1(xc1-m*a7*cos(t7*pi/180),(yc1-m*a7*sin(t7*pi/180)-j*n*sin(nt*pi/180)),n,nt,1.0,DARKGRAY);
}
setwritemode(0);
if(inbox(500,10,555,26)&&button()==1)
{mousehide();
mybutton(500,10,"EXIT",0,0);
mouseshow();
mousehold();
mousehide();
mybutton(500,10,"EXIT",1,7);
mouseshow();
exit(0);
}
if(buf()==56)
for(k=0;k<10000;k++){
switch (buf()){
case 18:{
mousehide();
mybutton(500,10,"EXIT",0,0);
mouseshow();
delay(4000);
mousehide();
mybutton(500,10,"EXIT",1,7);
mouseshow();
exit(0); }
default:break;
}
}
setwritemode(1);
}
}while(1);
}

drawline(double xo,double yo,double mo,double fujiao,double m,int color)
{
double x,y;
x=(xo+m*mo*cos(fujiao*pi/180));
y=(yo-m*mo*sin(fujiao*pi/180));
setcolor(color);
line (xo,yo,x,y);
}
drawline1(double xo,double yo,double mo,double fujiao,double m,int color)
{
double x,y;
x=(xo-m*mo*cos(fujiao*pi/180));
y=(yo-m*mo*sin(fujiao*pi/180));
setcolor(color);
line (xo,yo,x,y);
}
drawjijia(double x,double y,int shang)
{
setcolor(RED);
if (shang==1){
circle(x,y,3);
line(x-3.0,y+3.0,x-15.0,y+20.0);
moveto(x-15,(int)(y+20));
lineto((int)(x+15),(int)(y+20));
moveto((int)(x+15),(int)(y+20));
lineto(x+3,y+3);}
setcolor(RED);
if (shang==0){
circle((int)x,(int)y,3);
line (x-3,y-3,x-15,y-20);
moveto(x-15,y-20);
lineto(x+15,y-20);
moveto(x+15,y-20);
lineto(x+3,y-3);
}
}
double ca3mm1(double m1,double m2)
{
double temp;
temp = sqrt(m1*m1 + m2*m2);
return(temp);
}
double ca3fm1(double cosine,double sine)
{
float temp;
if (sine > 0 && cosine > 0)
temp = atan(sine / cosine) * 180 / pi;
if (sine > 0 && cosine < 0)
temp = (atan(sine / cosine) + pi) * 180 / pi;
if (sine < 0 && cosine < 0)
temp = (atan(sine / cosine) + pi) * 180 / pi;
if (sine < 0 && cosine > 0)
temp = (atan(sine / cosine) + 2 * pi) * 180 / pi;
return(temp);
}
double ca5fm2(double a6m,double a5m,double a4m,double a4f,int shang)
{
double temp,sine1,cosine1;
cosine1 = (a6m *a6m - a4m *a4m - a5m*a5m) / (2 * a4m * a5m);
sine1 = sqrt(1 - cosine1 *cosine1);
if (shang==0)
sine1 = sine1*(-1);
if (sine1 > 0 && cosine1 > 0)
temp = a4f + (atan(sine1 / cosine1) * 180 / pi);
if (sine1 > 0 && cosine1 < 0)
temp = a4f + ((atan(sine1 / cosine1) + pi) * 180 / pi);
if (sine1 < 0 && cosine1 < 0)
temp = a4f + ((atan(sine1 / cosine1) + pi) * 180 / pi);
if (sine1 < 0 && cosine1 > 0)
temp = a4f + ((atan(sine1 / cosine1) + 2 * pi) * 180 / pi);
return(temp);
}
double ca6fm2(double a4m ,double a4f,double a5m , double a5f)
{
double temp,sine1,cosine1;
sine1 = a4m * sin(a4f * pi / 180) + a5m * sin(a5f * pi / 180);
cosine1 = a4m * cos(a4f * pi / 180) + a5m * cos(a5f * pi / 180);

if (sine1 > 0 && cosine1 > 0)
temp = (atan(sine1 / cosine1) * 180 / pi);
if (sine1 > 0 && cosine1 < 0)
temp = ((atan(sine1 / cosine1) + pi) * 180 / pi);
if (sine1 < 0 && cosine1 < 0)
temp = ((atan(sine1 / cosine1) + pi) * 180 / pi);
if (sine1 < 0 && cosine1 > 0)
temp = ((atan(sine1 / cosine1) + 2 * pi) * 180 / pi);
return(temp);
}
initscreen()
{
int gd=DETECT,gm;
registerbgidriver(EGAVGA_driver);
initgraph(&gd,&gm,"");
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式