资源描述:
《直线插补流程图.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、直线插补与圆弧插补程序设计一.直线插补1.直线插补程序流程图开始输入相关数据:x0,y0,xe,ye,X=
2、xe-x0
3、Y=
4、ye-y0
5、n=X+Yx0>=0且y0>=0且xe>=0且ye>=0x0<=0且y0>=0且xe<=0且ye>=0YNCHABU1(F,n,Y,X)x0<=0且y0<=0且xe<=0且ye<=0结束CHABU2(F,n,Y,X)"跨象限运动"x0>=0且y0<=0且xe>=0且ye<=0CHABU3(F,n,Y,X)CHABU3(F,n,Y,X)N输出子函数计算结果直线插补程序
6、设计:#include"stdio.h"#include"math.h"voidCHABU1(intF,intn,intY,intX)/*第一象限调用函数*/{intnx=0,ny=0;for(;n>0;n--){printf("运算前:F=%d",F);if(F>=0){printf("需走步数:n=%d",n);printf("------向+xe方向走一步");F=F-Y;printf("F=%d",F);printf("+X");nx++;/*X方向走的总步数*/}else{print
7、f("需走步数:n=%d",n);printf("------向+ye方向走一步");F=F+X;printf("F=%d",F);printf("+Y");ny++;/*y方向走的总步数*/}}printf("nx=%d,ny=%d",nx,ny);}voidCHABU2(intF,intn,intY,intX)/*第二象限调用函数*/{intnx=0,ny=0;for(;n>0;n--){printf("运算前:F=%d",F);if(F>=0){printf("需走步数:n=%d
8、",n);printf("------向-xe方向走一步");F=F-Y;printf("F=%d",F);printf("-X");nx++;/*X方向走的总步数*/}else{printf("需走步数:n=%d",n);printf("------向+ye方向走一步");F=F+X;printf("F=%d",F);printf("+Y");ny++;/*y方向走的总步数*/}}printf("nx=%d,ny=%d",nx,ny);}voidCHABU3(intF,intn,in
9、tY,intX)/*第三象限调用函数*/{intnx=0,ny=0;for(;n>0;n--){printf("运算前:F=%d",F);if(F>=0){printf("需走步数:n=%d",n);printf("------向-xe方向走一步");F=F-Y;printf("F=%d",F);printf("-X");nx++;/*X方向走的总步数*/}else{printf("需走步数:n=%d",n);printf("------向-ye方向走一步");F=F+X;printf("
10、F=%d",F);printf("-Y");ny++;/*y方向走的总步数*/}}printf("nx=%d,ny=%d",nx,ny);}voidCHABU4(intF,intn,intY,intX)/*第四象限调用函数*/{intnx=0,ny=0;for(;n>0;n--){printf("运算前:F=%d",F);if(F>=0){printf("需走步数:n=%d",n);printf("------向+xe方向走一步");F=F-Y;printf("F=%d",F);print
11、f("+X");nx++;/*X方向走的总步数*/}else{printf("需走步数:n=%d",n);printf("------向-ye方向走一步");F=F+X;printf("F=%d",F);printf("-Y");ny++;/*y方向走的总步数*/}}printf("nx=%d,ny=%d",nx,ny);}main(){intF=0,X=0,Y=0,n,xe,ye,x0,y0,ny,nx;voidCHABU1(int,int,int,int);/*函数声明*/void
12、CHABU2(int,int,int,int);voidCHABU3(int,int,int,int);voidCHABU4(int,int,int,int);/*函数声明*/printf("输入相关数据");printf("x0=");scanf("%d",&x0);printf("xe=");scanf("%d",&xe);printf("y0=");scanf("%d",&y0);printf("ye=");scanf("%d",&ye);X=