Guest User

Untitled

a guest
Jan 7th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <time.h>
  5. int tab[4][3]={{1,2,3},{4,5,6},{7,8,9},{9,9,1}};
  6. int _Spr(int a,int b, int c)
  7. {
  8. if(a<=b&&a<=c)
  9. return a;
  10. else if(b<=a&&b<=c)
  11. return b;
  12. else
  13. return c;
  14. }
  15. int KrokKtorysieoplaca(int row, int col)
  16. { int i,j,suma=0;
  17. row=0;
  18. col=0;
  19. int min=100;
  20. int tab[4][3]={{1,7,3},{4,5,6},{7,0,9},{9,2,1}};
  21.  
  22. if (row==0)
  23. {min=_Spr(tab[3][col+1],tab[row+1][col+1],tab[row][col+1]);
  24. if (tab[3][col+1]==min)
  25. {row=3;
  26. col++;}
  27. if (tab[row+1][col+1]==min)
  28. {row++;
  29. col++;}
  30. if (tab[row][col+1]==min)
  31. {row;
  32. col++;}
  33. printf("%d\t%d",row,col);}
  34.  
  35. if ((row==1||row==2))
  36. {
  37. min=_Spr(tab[row-1][col+1],tab[row+1][col+1],tab[row][col+1]);
  38. if (tab[row-1][col+1]==min)
  39. {row--;
  40. col++;}
  41. if (tab[row+1][col+1]==min)
  42. {row++;
  43. col++;}
  44. if (tab[row][col+1]==min)
  45. {row;
  46. col++;}
  47. printf("%d\t%d",row,col);
  48. }
  49. //opcja po skosie w gore
  50. if (row==3)
  51. {
  52.  
  53. min=_Spr(tab[row-1][col+1],tab[0][col+1],tab[row][col+1]);
  54. if (tab[row-1][col+1]==min)
  55. {row--;
  56. col++;}
  57. if (tab[0][col+1]==min)
  58. {row=0;
  59. col++;}
  60. if (tab[row][col+1]==min)
  61. {row;
  62. col++;}
  63. printf("%d\t %d",row,col);}
  64.  
  65.  
  66. return 1;
  67. }
  68. int main()
  69. {
  70. int tab[4][3]={{1,7,3},{4,5,6},{7,0,9},{9,2,1}};
  71. int i,j,n,m;
  72.  
  73. for(i=0; i<4; i++)
  74. {
  75. for(j=0; j<3; j++)
  76. printf("%d ",tab[i][j]);
  77. printf("\n");
  78. }
  79. printf("\n\n%d",KrokKtorysieoplaca(4,3));
  80. return 0;}
Advertisement
Add Comment
Please, Sign In to add comment