Ðåôåðàò: Òðàíñïîðòíàÿ çàäà÷à
{
printf("founded\n\r");
fprintf(fil,"founded\n");
if((top2=(struct cik*)malloc(sizeof(struct cik)))==NULL)
abort();
if(!topnast1) topnast1=top2;
else top3 -> next=top2;
top3 = top2;
top2 -> next = NULL;
top2->ick = ik;
top2->jck = jk;
ch++;
top2->prnapr = 1;
pr("top2",top2);
napr = 2;
jk = nst;
perpr = perlev = 0;
} // **** IF *******
else
{
fprintf(fil,"Point not found ! Change direction to LEFT\n");
napr = 3;
perpr = 1;
}
break;
//***************** PRODOLZHENIE 2 POISKA ******************************
case 2:
printf("Search to the down --->");
fprintf(fil,"Search to the down --->");
if((nstr=nizpoisk(ik,jk))>=0)
{
if((top2=(struct cik*)malloc(sizeof(struct cik))) == NULL)
abort();
printf("founded\n\r"); fprintf(fil,"founded\n");
if(!topnast1) topnast1=top2;
else top3->next=top2;
top3=top2;
top2->next=NULL;
top2->ick = ik;
top2->jck = jk;
ch++;
top2->prnapr = 2;
pr("top2",top2);
napr = 3;
ik = nstr;
perniz=perver=0;
} //**** IF ********
else
{
fprintf(fil,"Point not found ! Change direction to UP\n");
napr = 4;
perniz = 1;
}
break;
case 3:
printf("Search to the left -->");
fprintf(fil,"Search to the left -->");
if((nst=levpoisk(ik,jk))>=0)
{
if((top2=(struct cik*)malloc(sizeof(struct cik))) == NULL)
abort();
printf("founded\n\r"); fprintf(fil,"founded\n");
if(!topnast1)
topnast1=top2;
else
top3->next=top2;
top3=top2;
top2->next=NULL;
top2->ick = ik;
top2->jck = jk;
ch++;
//************ PRODOLZHENIE 3 POISKA *************
top2->prnapr = 3;
pr("top2",top2);
napr = 4; jk = nst;
perlev = perpr = 0;
} // ******* IF *****
else{
fprintf(fil,"Point not found ! Change direction to RIGHT\n");
napr = 1;
perlev = 1;
}
break;
case 4:
printf("Search to the up --->");
fprintf(fil,"Search to the up --->");
if((nstr=verpoisk(ik,jk))>=0)
{
if((top2=(struct cik*)malloc(sizeof(struct cik)))==NULL)
abort();
printf("founded\n\r"); fprintf(fil,"founded\n");
if(!topnast1) topnast1=top2;
else top3->next=top2;
top3=top2;
top2->next=NULL;
top2->ick=ik;
top2->jck=jk;
ch++;
top2->prnapr = 4;
pr("top2",top2);
napr = 1;
ik = nstr;
perver = perniz = 0;
} // *****If **************
else
{
fprintf(fil,"Point not found ! Change direction to DOWN\n");
napr = 2;
perver = 1;
}
break;
} // ************ SWITCH ********************
// ************** PRODOLZHENIE 4 POISKA ********************
if(perlev == 1 && perpr == 1)
{
*(matr2+ik*n+jk) = 0;
ik = top3 ->ick;
jk = top3 ->jck;
napr = top3->prnapr;
top3 = topnast1;
printf("Zerro 1\n\r");
for(top2=topnast1;top2->next !=NULL;top2=top2->next)
top3 = top2;
top3 -> next=NULL;
perlev = perpr = 0; // if(ch == 1)
if(top2==top3)
{
fl3=1;
break;
}
else
{
top3->next=NULL;
free(top2);
ch--;
printf("Viynimaem tochky: (%d,%d)=%d\n",ik,jk,*(matr2+ik*n+jk));
fprintf(fil,"Viynimaem tochky: (%d,%d)=%d\n",ik,jk,*(matr2+ik*n+jk));
pr("top2",top2);
}
perpr = 0;
perlev = 0;
} // IF
if(perver == 1 && perniz == 1)
{
*(matr2+ik*n+jk)=0;
printf("Zerro 2\n\r");
ik=top3->ick;
jk = top3->jck;
napr = top3->prnapr;
top3 = topnast1;
for(top2 = topnast1;top2->next !=NULL;top2=top2->next)
top3 = top2; perver = perniz = 0;
if(top2==top3)
{
fl3=1;
break;
}
else
{
top3->next = NULL;
free(top2);
ch--;
// ******* PRODOLZHENIE 5 POISKA *********************
printf("Viynimaem tochky: (%d,%d) = %d\n",ik,jk,*(matr2+ik*n+jk));
fprintf(fil,"Viynimaem tochky: (%d,%d) = %d\n",ik,jk,*(matr2+ik*n+jk));
pr("top2",top2);