Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Диссертация_2013_Даулбаева ММ.doc
Скачиваний:
67
Добавлен:
10.03.2016
Размер:
2.34 Mб
Скачать

Продолжение приложения а

  1. fprintf(fil,"%5d",*(matr2+i*n+j));

  2. printf("%5d",*(matr2+i*n+j));

  3. }

  4. fprintf(fil,"\n");

  5. printf("\n");

  6. }

  7. fprintf(fil,"\n\n Переходим в Сраную, Мать её, Функцию cikl(ik,jk) \n");

  8. getch();

  9. cikl(ik,jk);

  10. return;

  11. } // abcikl

  12. // ********* FUNKCION POISKA CIKLA **************************

  13. int cikl(int ik,int jk)

  14. {

  15. int nst,nstr,i,j,

  16. perlev = 0,

  17. perpr = 0;

  18. int perver = 0,

  19. perniz = 0,

  20. fl = 0,

  21. fl3 = 1;

  22. int napr;

  23. struct cik { int prnapr;

  24. int ick;

  25. int jck;

  26. struct cik *next;

  27. } *topnast1 = NULL,

  28. *top2 = NULL,

  29. *top3 = NULL;

  30. ch = 0;

  31. if((top2 = (struct cik*)malloc(sizeof(struct cik))) == NULL)

  32. abort();

  33. if(!topnast1)

  34. {

  35. topnast1=top2;

  36. top3=top2;

  37. top3->ick=ik;

  38. top3->jck=jk;

  39. }

  40. else

  41. top3->next=top2;

  42. top3=top2;

  43. top2->next=NULL;

  44. top2->ick = ik;

  45. top2->jck = jk;

  46. ch++;

  47. fprintf(fil,"\n\nДо Условия while fl3 =%d \n",fl3);

  48. pr("top2",top2);

  49. fprintf(fil,"Весь цикл поиска сейчас начнется, надеюсь - \n что он будет не бесконечный или не бесполезный :( \n");

Продолжение приложения а

  1. printf("Весь цикл поиска сейчас начнется, надеюсь - \n что он будет не бесконечный или не бесполезный :( \n");

  2. printf("\n \t \t\tpress anykey to contunio\n");

  3. getch();

  4. while(fl3)

  5. {

  6. fl3=0;

  7. fl = 0;

  8. if((nst = prpoisk(ik,jk))>=0)

  9. {

  10. fprintf(fil,"\n\nВнимание!!!\n nst = %d \n",nst);

  11. fprintf(fil,"Ща будет поик идти ему бы...:Point found!\n");

  12. printf("И он пошел RIGHT:Point found !\n\r");

  13. napr = 2;

  14. jk = nst;

  15. top2->prnapr = 1;

  16. }

  17. else if((nstr = nizpoisk(ik,jk))>=0)

  18. {

  19. fprintf(fil,"DOWN: Point found !\n");

  20. printf("DOWN: Point found !\n\r");

  21. napr = 3;

  22. ik = nstr;

  23. top2->prnapr = 2;

  24. }

  25. else if((nst=levpoisk(ik,jk))>=0)

  26. {

  27. fprintf(fil,"LEFT:Point found !\n");

  28. printf("LEFT:Point found !\n\r");

  29. napr = 4;

  30. jk = nst;

  31. top2->prnapr = 3;

  32. }

  33. // **************** Prodolzhenie 1 poiska ***********************

  34. else if((nstr = verpoisk(ik,jk))>=0)

  35. {

  36. fprintf(fil,"UP:Point found !\n");

  37. printf("UP:Point found !\n\r");

  38. napr = 1;

  39. ik = nstr;

  40. top2->prnapr = 4;

  41. }

  42. else

  43. return(-1);

  1. while(!fl || *(matr2+ik*n+jk)!=-1)

  2. {

  3. fl=1;

  4. switch(napr)

  5. {

Продолжение приложения а

  1. case 1:

  2. printf("Search to the right --->");

  3. fprintf(fil,"Search to the right --->");

  4. if((nst = prpoisk(ik,jk))>=0)

  5. {

  6. printf("founded\n\r");

  7. fprintf(fil,"founded\n");

  8. if((top2=(struct cik*)malloc(sizeof(struct cik)))==NULL)

  9. abort();

  10. if(!topnast1) topnast1=top2;

  11. else top3 -> next=top2;

  12. top3 = top2;

  13. top2 -> next = NULL;

  14. top2->ick = ik;

  15. top2->jck = jk;

  16. ch++;

  17. top2->prnapr = 1;

  18. pr("top2",top2);

  19. napr = 2;

  20. jk = nst;

  21. perpr = perlev = 0;

  22. } // **** IF *******

  23. else

  24. {

  25. fprintf(fil,"Point not found ! Change direction to LEFT\n");

  26. napr = 3;

  27. perpr = 1;

  28. }

  29. break;

  30. //***************** PRODOLZHENIE 2 POISKA ******************************

  31. case 2:

  32. printf("Search to the down --->");

  33. fprintf(fil,"Search to the down --->");

  34. if((nstr=nizpoisk(ik,jk))>=0)

  35. {

  36. if((top2=(struct cik*)malloc(sizeof(struct cik))) == NULL)

  37. abort();

  38. printf("founded\n\r"); fprintf(fil,"founded\n");

  39. if(!topnast1) topnast1=top2;

  40. else top3->next=top2;

  41. top3=top2;

  42. top2->next=NULL;

  43. top2->ick = ik;

  44. top2->jck = jk;

  45. ch++;

  46. top2->prnapr = 2;

  47. pr("top2",top2);

  48. napr = 3;

  49. ik = nstr;