當前位置:編程學習大全網 - 源碼下載 - 新西蘭源代碼系統

新西蘭源代碼系統

#定義MAXX 50

#定義最大值50

# include & ltstdio.h & gt

# include & ltstdlib.h & gt

# include & ltalloc.h & gt

# include & ltconio.h & gt

# include & ltgraphics.h & gt

# include & ltstring.h & gt

/* = = = = = = = = = = = = = = = = =利用趨勢面加權最小二乘法計算點高程系統= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

# include & ltconio.h & gt

# include & ltstdio.h & gt

# include & ltmath.h & gt

int CN1,CN2,NP 1;/*-CN1,CN2為點間距,NP1為測點數-*/

int X0,Y0;/*-x0,y0為網格起點坐標-*/

void wzjs(int n,int m,float *x,float *y,float *z,float **bb)

{

int i,j,k,k0,k1,n0,hh = 0;

double cnum,x1,x2,y1,y2,xt,yt,xxt,yyt,xyt,zt,A,B,c;

double e[10][10]={0,u[10]= { 0;

for(I = 0;我& lt= n;i++)/*-柱網(X方向)-*/

{

a = X0+I * cn 1;

for(j = 0;j & lt= m;j++)/*-水平網(Y方向)-*/

{

b = Y0+j * CN2;

for(k = 0;k & lt10;k++)

{

u[k]= 0;

for(k0 = 0;k0 & lt10;k0++)e[k][k0]= 0;

for(k = 0;k & ltNP 1;K++) /* -高斯法計算曲面方程的值和網格點的值。

{

hh = 0;

if(A = = *(x+k)& amp;& ampB==*(y+k))

{

*(*(b b+ I)+j)= *(z+k);

hh = 1;打破;

x 1 = *(x+k);y 1 = *(y+k);

x2 = x 1 * x 1;y2 = y 1 * y 1;

cnum =(x 1-A)*(x 1-A)+(y 1-B)*(y 1-B);

cnum = 1/cnum;

XT = cnum * x 1;yt = cnum * y 1;

xxt = x2 * cnumyyt = y2 * cnumxyt = x 1 * yt;

e[1][1]= e[1][1]+cnum;e[1][2]= e[1][2]+XT;

e[1][3]= e[1][3]+yt;e[1][4]= e[1][4]+xyt;

e[1][5]= e[1][5]+xxt;e[1][6]= e[1][6]+yyt;

e[2][4]= e[2][4]+x2 * yt;e[2][5]= e[2][5]+x2 * XT;

e[2][6]= e[2][6]+y2 * XT;e[3][6]= e[3][6]+y2 * yt;

e[4][4]= e[4][4]+x2 * yyt;e[4][5]= e[4][5]+x2 * xyt;

e[4][6]= e[4][6]+y2 * xyt;e[5][5]= e[5][5]+x2 * xxt;

e[6][6]= e[6][6]+y2 * yyt;

ZT = *(z+k)* cnum;

u[1]= u[1]+ZT;u[2]= u[2]+x 1 * ZT;

u[3]= u[3]+y 1 * ZT;u[4]= u[4]+x 1 * y 1 * ZT;

u[5]= u[5]+x2 * ZT;u[6]= u[6]+y2 * ZT;

if(hh==1)繼續;

e[2][2]= e[1][5];e[2][3]= e[1][4];e[3][3]= e[1][6];

e[3][4]= e[2][6];e[3][5]= e[2][4];e[5][6]= e[4][4];

for(k = 1;k & lt6;k++)

for(k0 = k+1;k0 & lt7;k0++)

e[k0][k]= e[k][k0];

for(k = 1;k & lt7;k++)e[k][7]= u[k];

n0 = 6;

for(k = 1;k & ltn0;k++)

for(k0 = k+1;k0 & ltn0+1;k0++)

for(k 1 = k+1;k 1 & lt;n0+2;k1++)

e[k0][k 1]= e[k0][k 1]-e[k0][k]* e[k][k 1]/e[k][k];

u[n0]= e[n0][n0+1]/e[n0][n0];

for(k = n0-1;k & gt0;k -)

{

c = 0;

for(k0 = k+1;k0 & ltn0+1;k0++)

c = c+e[k][k0]* u[k0];

u[k]=(e[k][n0+1]-c)/e[k][k];

*(*(B B+I)+j)= u[1]+A *(u[2]+B * u[4]+A * u[5])+B *(u[3]+B * u[6]);

/*=============================================*/

/*繪制等值線/

/*=============================================*/

#包含“hmain.h”

float flagx[MAXX][MAXY],flagy[MAXX][MAXY];

int i1,i2,j1,J2;

int zdzz(float *a1,float *b1,float *a2,float * B2);

void drawln(float a0,float b0,int n,int m,float ratox,float ratoy,char *item)

{

float a1,b1,a2,b2,sin,xa[1000]={0,Yb[1000]= { 0;

int k = 1;

a2 = a0b2 = b0a 1 = A0+5;b 1 = B0+5;

xa[0]= A0;Yb[0]= B0;

做{/*-畫壹條線-*/

如果(zdzz(& amp;a1。b1。a2和ampb2)==1)

{

line(a2/ratox,getmaxy()-b2/ratoy,a0/ratox,get maxy()-B0/ratoy);

打破;

line(a1/ratox,getmaxy()-b1/ratoy,a2/ratox,get maxy()-B2/ratoy);

xa[k]= a2/ratox;Yb[k]= get maxy()-B2/ratoy;

k++;

while(a2 & gt;0 & amp& ampb2 & gt0 & amp& ampi2 & ltn & amp& ampj2 & ltm);

k = k/2;

if((xa[k+1]-xa[k-1])& lt;0.3)sin = VERT _ DIR;/*-寫出等價的數字-*/

else if((Yb[k+1]-Yb[k-1])& lt;0.3)sin = VERT _ DIR;

else sin =(Yb[k+1]-Yb[k-1])/(xa[k+1]-xa[k-1]);

settextstyle(TRIPLEX_FONT,sin,3);

setcolor(白色);

settextjustify(CENTER_TEXT,CENTER _ TEXT);

outtextxy(xa[k],yb[k],item);

setcolor(綠色);

#包含“hmain.h”

/*讀入數據*/

void rcvda(char *flname,float *x,float *y,float *z,int * n0);

/*劃分網格並計算節點*/

void wzjs(int n,int m,float *x,float *y,float *z,float * * bb);

/*計算等效點*/

void bzdzd(int w,int *n,int *m,float * * bb);

/*繪制等值線*/

void xcln(int n,int m,float ratox,float ratoy,char * item);

/* -全局變量*/

int CN1,CN2,NP 1;

int X0,Y0,kk,kk 1;

float flagx[MAXX][MAXY],flagy[MAXX][MAXY];

/* void map mode();-圖形模式*/

/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

void mapmode()

{

int gdriver=DETECT,gmode,errorcode/*-自動檢測-*/

error code = registerbgidriver(EGA VGA _ driver);

if(錯誤代碼& lt0)

{

printf("圖形錯誤:n%s ",grapherrormsg(error code));/*-報告註冊錯誤-*/

printf(" n按任意鍵停止:");

getch();

退出(1);

init graph(& amp;g driver & amp;gmode,“”;/*-初始化圖形模式-*/

error code = graph result();

if(errorcode!=grOK)

{

printf("圖形錯誤:n%s ",grapherrormsg(error code));

printf(" n按任意鍵停止:");

getch();

退出(1);

/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

主()

{

int i,j,n,m,w,pn1,pn2,pn3,n0=0,ccc

float x[MAXX],x0[MAXX],y[MAXY],y0[MAXY],z[MAXX],ratox,ratoy

浮動mx,my,mz,nx,ny,NZ;

char flname[12],item[10],ch;

float bb 1[MAXX][MAXY]= { 0;

float * bb[MAXX];

for(I = 0;我& ltMAXXi++)

{

bb[I]= & amp;bb 1[I][0];/* -將數組歸零。

clr SCR();

map mode();/* -設置圖形模式。

Printf("請輸入數據文件名:");

scanf("%s ",flname);

rcvda(flname,x,y,z和ampn0);/*-從文件中讀取數據-*/

MX = NX = x[0];

my = ny = y[0];

mz = NZ = z[0];

for(I = 0;我& ltn0;i++)/*-確定數據範圍-*/

{

if(x[I]& gt;MX)MX = x[I];

else if(x[I]& lt;NX)NX = x[I];

if(y[I]& gt;my)my = x[I];

else if(y[I]& lt;ny)ny = y[I];

if(z[I]& gt;mz)mz = z[I];

else if(z[I]& lt;NZ)NZ = z[I];

NP 1 = n0;

printf("nmaxx=%。lf minx=%。lfn”、mx、NX);

printf("nmaxy=%。如果miny=%。lfn”,my,ny);

printf("nmaxz=%。lf minz=%。lfn”、mz、NZ);

Printf("n請輸入網格間距:");

scanf("%d ",& ampcn 1);

CN2 = cn 1;

n =(int)(MX-NX)/cn 1;/*-計算網格數-*/

m =(int)(my-ny)/CN2;

x0 =(int)(NX/cn 1);X0 = X0 * cn 1;/*-計算起點的坐標-*/

y0 =(int)(ny/CN2);Y0 = Y0 * CN2

ratox = n * cn 1/640.0;ratoy = m * CN2/480.0;/*-X,Y方向系數-*/

wzjs(n,m,x,y,z,bb);/*-計算等值點-*/

Printf("n請輸入最小輪廓值:");

scanf("%d ",& amppn 1);

Printf("n請輸入最大等值線值:");

scanf("%d ",& amppn2);

Printf("n請輸入輪廓間距:");

scanf("%d ",& amppn3);

clear device();

for(I = 0;我& ltn0;i++)

{

X0[I]=(x[I]-X0)/ratox;/*-計算每個點的屏幕坐標-*/

Y0[I]=(y[I]-Y0)/ratoy;

setcolor(紅色);

circle(x0[i],getmaxy()-y0[i],3);/* -畫壹個圈表示值點。

for(w = pn 1;w & lt= pn2W+=pn3) /* -等值線壹壹形成。

{

bzdzd(w & amp;n & amp;m,bb);/*-計算等值點-*/

itoa(w,item,10);/*-將整數w轉換為用於標註的字符-*/

xcln(n,m,ratox,ratoy,item);/*-繪制等值線-*/

getch();

closegraph();

/* = = = = = = = = = = = = = =從文件中讀取數據= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

#包含“hmain.h”

void rcvda(char *flname,float *x,float *y,float *z,int *n0)

{

文件*流;

If ((stream = fopen (flname," rt))= = null)/*-打開文件/

{

printf(" n無法打開%s:",flname);

getch();

退出(0);

而(!feof(stream))/*-讀取文件直到結束-*/

{

fscanf(stream," %f,",(x+* n0));

fscanf(stream," %f,",(y+* n0));

fscanf(stream," %f,",(z+* n0));

* n0 = * n0+1;/*-指定區域的變更-*/

fclose(流);

/* = = = = = = = = = = = = = = = = =利用趨勢面加權最小二乘法計算點高程系統= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

# include & ltconio.h & gt

# include & ltstdio.h & gt

# include & ltmath.h & gt

int CN1,CN2,NP 1;/*-CN1,CN2為點間距,NP1為測點數-*/

int X0,Y0;/*-x0,y0為網格起點坐標-*/

void wzjs(int n,int m,float *x,float *y,float *z,float **bb)

{

int i,j,k,k0,k1,n0,hh = 0;

double cnum,x1,x2,y1,y2,xt,yt,xxt,yyt,xyt,zt,A,B,c;

double e[10][10]={0,u[10]= { 0;

for(I = 0;我& lt= n;i++)/*-柱網(X方向)-*/

{

a = X0+I * cn 1;

for(j = 0;j & lt= m;j++)/*-水平網(Y方向)-*/

{

b = Y0+j * CN2;

for(k = 0;k & lt10;k++)

{

u[k]= 0;

for(k0 = 0;k0 & lt10;k0++)e[k][k0]= 0;

for(k = 0;k & ltNP 1;K++) /* -高斯法計算曲面方程的值和網格點的值。

{

hh = 0;

if(A = = *(x+k)& amp;& ampB==*(y+k))

{

*(*(b b+ I)+j)= *(z+k);

hh = 1;打破;

x 1 = *(x+k);y 1 = *(y+k);

x2 = x 1 * x 1;y2 = y 1 * y 1;

cnum =(x 1-A)*(x 1-A)+(y 1-B)*(y 1-B);

cnum = 1/cnum;

XT = cnum * x 1;yt = cnum * y 1;

xxt = x2 * cnumyyt = y2 * cnumxyt = x 1 * yt;

e[1][1]= e[1][1]+cnum;e[1][2]= e[1][2]+XT;

e[1][3]= e[1][3]+yt;e[1][4]= e[1][4]+xyt;

e[1][5]= e[1][5]+xxt;e[1][6]= e[1][6]+yyt;

e[2][4]= e[2][4]+x2 * yt;e[2][5]= e[2][5]+x2 * XT;

e[2][6]= e[2][6]+y2 * XT;e[3][6]= e[3][6]+y2 * yt;

e[4][4]= e[4][4]+x2 * yyt;e[4][5]= e[4][5]+x2 * xyt;

e[4][6]= e[4][6]+y2 * xyt;e[5][5]= e[5][5]+x2 * xxt;

e[6][6]= e[6][6]+y2 * yyt;

ZT = *(z+k)* cnum;

u[1]= u[1]+ZT;u[2]= u[2]+x 1 * ZT;

u[3]= u[3]+y 1 * ZT;u[4]= u[4]+x 1 * y 1 * ZT;

u[5]= u[5]+x2 * ZT;u[6]= u[6]+y2 * ZT;

if(hh==1)繼續;

e[2][2]= e[1][5];e[2][3]= e[1][4];e[3][3]= e[1][6];

e[3][4]= e[2][6];e[3][5]= e[2][4];e[5][6]= e[4][4];

for(k = 1;k & lt6;k++)

for(k0 = k+1;k0 & lt7;k0++)

e[k0][k]= e[k][k0];

for(k = 1;k & lt7;k++)e[k][7]= u[k];

n0 = 6;

for(k = 1;k & ltn0;k++)

for(k0 = k+1;k0 & ltn0+1;k0++)

for(k 1 = k+1;k 1 & lt;n0+2;k1++)

e[k0][k 1]= e[k0][k 1]-e[k0][k]* e[k][k 1]/e[k][k];

u[n0]= e[n0][n0+1]/e[n0][n0];

for(k = n0-1;k & gt0;k -)

{

c = 0;

for(k0 = k+1;k0 & ltn0+1;k0++)

c = c+e[k][k0]* u[k0];

u[k]=(e[k][n0+1]-c)/e[k][k];

*(*(B B+I)+j)= u[1]+A *(u[2]+B * u[4]+A * u[5])+B *(u[3]+B * u[6]);

/* = = = = = = = = = = = = = = = = = = =標註網格兩側是否有高程等效點= = = = = = = = = = = = = = = = = = = = = = = =

#包含“hmain.h”

float flagx[MAXX][MAXY],flagy[MAXX][MAXY];/*-等價標記-*/

void bzdzd(int w,int *n,int *m,float **bb)

{

int i,j;

浮點m1,m2;

for(I = 0;我& lt* n+1;i++)/*-柱網(X方向)-*/

for(j = 0;j & lt* m;j++)

{

m 1 = w-*(*(b b+I)+j);if(m 1 = = 0)m 1 =-0.01;

m2 = w-*(*(b b+I)+j+1);if(m2 = = 0)m2 =-0.01;

if(m 1 * m2 & lt;0)flagy[I][j]= m 1/(m 1-m2);

else flagy[I][j]=-2;

for(I = 0;我& lt* n;i++)/*-水平網(Y方向)-*/

for(j = 0;j & lt* m+1;j++)

{

m 1 = w-*(*(b b+I)+j);if(m 1 = = 0)m 1 =-0.01;

m2 = w-*(*(b b+ I+1)+j);if(m2 = = 0)m2 =-0.01;

if(m 1 * m2 & lt;0)flagx[I][j]= m 1/(m 1-m2);

else flagx[I][j]=-2;

/* = = = = = = = = = = = = = =輪廓追蹤= = = = = = = = = = = = = = = = = = =/

#包含“hmain.h”

float flagx[MAXX][MAXY],flagy[MAXX][MAXY];

int CN1,CN2,i1,i2,j1,J2;

int zdzz(float *a1,float *b1,float *a2,float *b2)

{

int flag,i0,j0,s 1;

如果(j2 & gtj 1)flag = 1;

其他

如果(i2 & gtI 1)flag = 2;

其他

if(* B2 = = J2 * CN2)flag = 3;

其他

flag = 4;

開關(標誌)

{

案例1:

if(flagy[I2][J2]& gt;0)/*-判斷向左-*/

{

i0 = i2j0 = j2s 1 = 0;

else if(flagy[I2+1][J2]& gt;0)

{

i0 = I2+1;j0 = j2s 1 = 0;

else if(flagx[I2][J2+1]& gt;0)

{

i0 = i2j0 = J2+1;s 1 = 1;

否則返回1;

打破;

案例二:

if(flagx[I2][J2]& gt;0)/*-判斷要上去-*/

{

i0 = i2j0 = j2s 1 = 1;

else if(flagx[I2][J2+1]& gt;0)

{

i0 = i2j0 = J2+1;s 1 = 1;

else if(flagy[I2+1][J2]& gt;0)

{

i0 = I2+1;j0 = j2s 1 = 0;

否則返回1;

打破;

案例三:

if(flagy[I2][J2-1]& gt;0)/*-判斷向右-*/

{

i0 = i2j0 = J2-1;s 1 = 0;

else if(flagy[I2+1][J2-1]>;0)

{

i0 = I2+1;j0 = J2-1;s 1 = 0;

else if(flagx[I2][J2-1]& gt;0)

{

i0 = i2j0 = J2-1;s 1 = 1;

否則返回1;

打破;

案例4:

if(flagx[I2-1][J2]& gt;0)/*-判斷要下去-*/

{

i0 = I2-1;j0 = j2s 1 = 1;

else if(flagx[I2-1][J2+1]>;0)

{

i0 = I2-1;j0 = J2+1;s 1 = 1;

else if(flagy[I2-1][J2]& gt;0)

{

i0 = I2-1;j0 = j2s 1 = 0;

否則返回1;

打破;

I 1 = I2;j 1 = J2;i2 = i0j2 = j0

* a 1 = * a2;* b 1 = * B2;

* a2 =(I2+s 1 * flagx[I2][J2])* cn 1;

* B2 =(J2+(1-s 1)* flagy[I2][J2])* CN2;

if(s 1 = = 0)flagy[I2][J2]=-2;/*-使用的徽標-*/

else flagx[I2][J2]=-2;

返回0;

/*=============================================*/

/*繪制等值線/

/*=============================================*/

#包含“hmain.h”

float flagx[MAXX][MAXY],flagy[MAXX][MAXY];

int i1,i2,j1,J2;

int zdzz(float *a1,float *b1,float *a2,float * B2);

void drawln(float a0,float b0,int n,int m,float ratox,float ratoy,char *item)

{

float a1,b1,a2,b2,sin,xa[1000]={0,Yb[1000]= { 0;

int k = 1;

a2 = a0b2 = b0a 1 = A0+5;b 1 = B0+5;

xa[0]= A0;Yb[0]= B0;

做{/*-畫壹條線-*/

如果(zdzz(& amp;a1。b1。a2和ampb2)==1)

{

line(a2/ratox,getmaxy()-b2/ratoy,a0/ratox,get maxy()-B0/ratoy);

打破;

line(a1/ratox,getmaxy()-b1/ratoy,a2/ratox,get maxy()-B2/ratoy);

xa[k]= a2/ratox;Yb[k]= get maxy()-B2/ratoy;

k++;

while(a2 & gt;0 & amp& ampb2 & gt0 & amp& ampi2 & ltn & amp& ampj2 & ltm);

k = k/2;

if((xa[k+1]-xa[k-1])& lt;0.3)sin = VERT _ DIR;/*-寫出等價的數字-*/

else if((Yb[k+1]-Yb[k-1])& lt;0.3)sin = VERT _ DIR;

else sin =(Yb[k+1]-Yb[k-1])/(xa[k+1]-xa[k-1]);

settextstyle(TRIPLEX_FONT,sin,3);

setcolor(白色);

settextjustify(CENTER_TEXT,CENTER _ TEXT);

outtextxy(xa[k],yb[k],item);

setcolor(綠色);

/*=============================================*/

/*找到線頭,畫等值線/

/*=============================================*/

#包含“hmain.h”

int CN1,CN2

void drawln(float a0,float b0,int n,int m,float ratox,float ratoy,char * item);

int i1,i2,j1,J2;

float flagx[MAXX][MAXY],flagy[MAXX][MAXY];

void xcln(int n,int m,float ratox,float ratoy,char *item)

{

int w,w 1;

浮點a0,B0;

for(w = 0;w & ltn;W++) /* -從底層尋找起點。

if(flagx[w][0]& gt;0)

{

I 1 = w;I2 = w;j 1 =-1;J2 = 0;

A0 =(I2+flagx[w][0])* cn 1;

flagx[w][0]=-2;B0 = 0;

drawln(a0,b0,n,m,ratox,ratoy,item);

for(w = 0;w & ltm;W++) /* -從左邊尋找起點。

if(flagy[0][w]& gt;0)

{

I 1 =-1;I2 = 0;j 1 = w;J2 = w;

B0 =(J2+flagy[0][w])* CN2;

flagy[0][w]=-2;A0 = 0;

drawln(a0,b0,n,m,ratox,ratoy,item);

for(w = 0;w & ltn;W++) /* -從上面找壹個起點。

if(flagx[w][m]& gt;0)

{

I 1 = w;I2 = w;j 1 = m;J2 = m;

A0 =(I2+flagx[I2][J2])* cn 1;

b0 = m * CN2flagx[I2][J2]=-2;

drawln(a0,b0,n,m,ratox,ratoy,item);

for(w = 0;w & ltm;W++) /* -從右邊尋找起點。

if(flagy[n][w]& gt;0)

{

I 1 = n;I2 = n;j 1 = w;J2 = w;

B0 =(J2+flagy[I2][J2])* CN2;

A0 = n * cn 1;flagy[I2][J2]=-2;

drawln(a0,b0,n,m,ratox,ratoy,item);

for(w = 1;w & ltn;W++) /* -從網格中尋找起點。

for(w 1 = 0;w 1 & lt;m;w1++)

if(flagy[w][w 1]& gt;0)

{

I 1 =-1;I2 = w;j 1 = w 1;J2 = w 1;

A0 = I2 * cn 1;

B0 =(J2+flagy[I2][J2])* CN2;flagy[I2][J2]=-2;

drawln(a0,b0,n,m,ratox,ratoy,item);

/* = = = = = = = = = = = = = = = = = =標註網格兩側是否有高程等值點= = = = = = = = = = = = = = = = = = = = = = = = =

#包含“hmain.h”

float flagx[MAXX][MAXY],flagy[MAXX][MAXY];/*-等價標記-*/

void bzdzd(int w,int *n,int *m,float **bb)

{

int i,j;

浮點m1,m2;

for(I = 0;我& lt* n+1;i++)/*-柱網(X方向)-*/

for(j = 0;j & lt* m;j++)

{

m 1 = w-*(*(b b+I)+j);if(m 1 = = 0)m 1 =-0.01;

m2 = w-*(*(b b+I)+j+1);if(m2 = = 0)m2 =-0.01;

if(m 1 * m2 & lt;0)flagy[I][j]= m 1/(m 1-m2);

else flagy[I][j]=-2;

for(I = 0;我& lt* n;i++)/*-水平網(Y方向)-*/

for(j = 0;j & lt* m+1;j++)

{

m 1 = w-*(*(b b+I)+j);if(m 1 = = 0)m 1 =-0.01;

m2 = w-*(*(b b+ I+1)+j);if(m2 = = 0)m2 =-0.01;

if(m 1 * m2 & lt;0)flagx[I][j]= m 1/(m 1-m2);

else flagx[I][j]=-2;

/* = = = = = = = = = = = = = =從文件中讀取數據= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

#包含“hmain.h”

void rcvda(char *flname,float *x,float *y,float *z,int *n0)

{

文件*流;

If ((stream = fopen (flname," rt))= = null)/*-打開文件/

{

printf(" n無法打開%s:",flname);

getch();

退出(0);

而(!feof(stream))/*-讀取文件直到結束-*/

{

fscanf(stream," %f,",(x+* n0));

fscanf(stream," %f,",(y+* n0));

fscanf(stream," %f,",(z+* n0));

* n0 = * n0+1;/*-指定區域的變更-*/

fclose(流);

/*=============================================*/

/*找到線頭,畫等值線/

/*=============================================*/

#包含“hmain.h”

int CN1,CN2

void drawln(float a0,float b0,int n,int m,float ratox,float ratoy,char * item);

int i1,i2,j1,J2;

float flagx[MAXX][MAXY],flagy[MAXX][MAXY];

void xcln(int n,int m,float ratox,float ratoy,char *item)

{

int w,w 1;

浮點a0,B0;

for(w = 0;w & ltn;W++) /* -從底層尋找起點。

if(flagx[w][0]& gt;0)

{

I 1 = w;I2 = w;j 1 =-1;J2 = 0;

A0 =(I2+flagx[w][0])* cn 1;

flagx[w][0]=-2;B0 = 0;

drawln(a0,b0,n,m,ratox,ratoy,item);

for(w = 0;w & ltm;W++) /* -從左邊尋找起點。

if(flagy[0][w]& gt;0)

{

I 1 =-1;I2 = 0;j 1 = w;J2 = w;

B0 =(J2+flagy[0][w])* CN2;

flagy[0][w]=-2;A0 = 0;

drawln(a0,b0,n,m,ratox,ratoy,item);

for(w = 0;w & ltn;W++) /* -從上面找壹個起點。

if(flagx[w][m]& gt;0)

{

I 1 = w;I2 = w;j 1 = m;J2 = m;

A0 =(I2+flagx[I2][J2])* cn 1;

b0 = m * CN2flagx[I2][J2]=-2;

drawln(a0,b0,n,m,ratox,ratoy,item);

for(w = 0;w & ltm;W++) /* -從右邊尋找起點。

if(flagy[n][w]& gt;0)

{

I 1 = n;I2 = n;j 1 = w;J2 = w;

B0 =(J2+flagy[I2][J2])* CN2;

A0 = n * cn 1;flagy[I2][J2]=-2;

drawln(a0,b0,n,m,ratox,ratoy,item);

for(w = 1;w & ltn;W++) /* -在網格中尋找起點。

for(w 1 = 0;w 1 & lt;m;w1++)

if(flagy[w][w 1]& gt;0)

{

I 1 =-1;I2 = w;j 1 = w 1;J2 = w 1;

A0 = I2 * cn 1;

B0 =(J2+flagy[I2][J2])* CN2;flagy[I2][J2]=-2;

drawln(a0,b0,n,m,ratox,ratoy,item);

/* = = = = = = = = = = = = = =輪廓追蹤= = = = = = = = = = = = = = = = = = =/

#包含“hmain.h”

float flagx[MAXX][MAXY],flagy[MAXX][MAXY];

int CN1,CN2,i1,i2,j1,J2;

int zdzz(float *a1,float *b1,float *a2,float *b2)

{

int flag,i0,j0,s 1;

如果(j2 & gtj 1)flag = 1;

其他

如果(i2 & gtI 1)flag = 2;

其他

if(* B2 = = J2 * CN2)flag = 3;

其他

flag = 4;

開關(標誌)

{

案例1:

if(flagy[I2][J2]& gt;0)/*-判斷向左-*/

{

i0 = i2j0 = j2s 1 = 0;

else if(flagy[I2+1][J2]& gt;0)

{

i0 = I2+1;j0 = j2s 1 = 0;

else if(flagx[I2][J2+1]& gt;0)

{

i0 = i2j0 = J2+1;s 1 = 1;

否則返回1;

打破;

案例二:

if(flagx[I2][J2]& gt;0)/*-判斷要上去-*/

{

i0 = i2j0 = j2s 1 = 1;

else if(flagx[I2][J2+1]& gt;0)

{

i0 = i2j0 = J2+1;s 1 = 1;

else if(flagy[I2+1][J2]& gt;0)

{

i0 = I2+1;j0 = j2s 1 = 0;

否則返回1;

打破;

案例三:

if(flagy[I2][J2-1]& gt;0)/*-判斷向右-*/

{

i0 = i2j0 = J2-1;s 1 = 0;

else if(flagy[I2+1][J2-1]>;0)

{

i0 = I2+1;j0 = J2-1;s 1 = 0;

else if(flagx[I2][J2-1]& gt;0)

{

i0 = i2j0 = J2-1;s 1 = 1;

否則返回1;

打破;

案例4:

if(flagx[I2-1][J2]& gt;0)/*-判斷要下去-*/

{

i0 = I2-1;j0 = j2s 1 = 1;

else if(flagx[I2-1][J2+1]>;0)

{

i0 = I2-1;j0 = J2+1;s 1 = 1;

else if(flagy[I2-1][J2]& gt;0)

{

i0 = I2-1;j0 = j2s 1 = 0;

否則返回1;

打破;

I 1 = I2;j 1 = J2;i2 = i0j2 = j0

* a 1 = * a2;* b 1 = * B2;

* a2 =(I2+s 1 * flagx[I2][J2])* cn 1;

* B2 =(J2+(1-s 1)* flagy[I2][J2])* CN2;

if(s 1 = = 0)flagy[I2][J2]=-2;/*-使用的徽標-*/

else flagx[I2][J2]=-2;

返回0;

  • 上一篇:源代碼定制企業
  • 下一篇:OCR文字識別軟件哪個易用可網上下載
  • copyright 2024編程學習大全網