回复 2楼 qq1023569223
//(A1)对flag_posi_c进行赋值
for(i9=1;i9<=xcou;i9+=1){
a2=boten[i9][1];
b2=boten[i9][2];
c3=(a2-a3)*(a2-a3)+(b2-b3)*(b2-b3);
if(c3<len2_c){
//len2_c,len1_c是前边代码计算的两个值,根据c3与两个值的关系,对flag_posi_c进行赋值
flag_posi_c[i9]=2;
}
else if(c3>len1_c){
flag_posi_c[i9]=1;
}
else{
flag_posi_c[i9]=0;
}
}
//(A2)测试 flag_posi_c绘图(A2和A4的绘图不一样,把flag_posi_c[]输出,发现有部分元素位置发生了变化。
int i1000;
i1000=StrToInt(Edit35->Text);
//测试输出"flag_posi_c1.txt"
FILE *flag_posi_c1;
if((flag_posi_c1=fopen("flag_posi_c1.txt","wt")) ==NULL)return;
if(CheckBox50->Checked==true){
for(i9=1;i9<=xcou;i9+=1){
fprintf(flag_posi_c1,"%d\n",flag_posi_c[i9]);
if(flag_posi_c[i9]==i1000){
a=x0+cc*boten[i9][1];
b=y0-cc*boten[i9][2];
Image1->Canvas->Pen->Color=clBlack;
Image1->Canvas->MoveTo(a,b);
Image1->Canvas->LineTo(a+1,b+1);
}
}
}
fclose(flag_posi_c1);
//测试输出"flag_posi_c1.txt"
//测试 flag_posi_c绘图
//(A3)与flag_posi_c无关的操作
for(i9=1;i9<=iax1[1];i9+=1){
a2=boten[i9][1];
b2=boten[i9][2];
mxcou_c=mxcou_c+1;
mxboten_c[mxcou_c][1]=boten[i9][1];
mxboten_c[mxcou_c][2]=boten[i9][2];
mxkind_c[mxcou_c]=kind[i9];
ia10_c=ia10_c+1;
iax3_c=iax3_c+1;
flag_v_c[mxcou_c]=0;
flag_v300[mxcou_c]=flag_v[i9];
}
//与flag_posi_c无关的操作
//(A4)测试flag_posi_c
//测试输出"flag_posi_c2.txt"
FILE *flag_posi_c2;
if((flag_posi_c2=fopen("flag_posi_c2.txt","wt")) ==NULL)return;
if(CheckBox55->Checked==true){
i1000=StrToInt(Edit37->Text);
for(i9=1;i9<=xcou;i9+=1){
fprintf(flag_posi_c2,"%d\n",flag_posi_c[i9]);
if(flag_posi_c[i9]==i1000){
a=x0+cc*boten[i9][1];
b=y0-cc*boten[i9][2];
Image1->Canvas->Pen->Color=clBlack;
Image1->Canvas->MoveTo(a,b);
Image1->Canvas->LineTo(a+1,b+1);
}
}
}
fclose(flag_posi_c2);
//测试输出"flag_posi_c2.txt"
//测试flag_posi_c