Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <time.h>
- int tab[4][3]={{1,2,3},{4,5,6},{7,8,9},{9,9,1}};
- int _Spr(int a,int b, int c)
- {
- if(a<=b&&a<=c)
- return a;
- else if(b<=a&&b<=c)
- return b;
- else
- return c;
- }
- int KrokKtorysieoplaca(int row, int col)
- { int i,j,suma=0;
- row=0;
- col=0;
- int min=100;
- int tab[4][3]={{1,7,3},{4,5,6},{7,0,9},{9,2,1}};
- if (row==0)
- {min=_Spr(tab[3][col+1],tab[row+1][col+1],tab[row][col+1]);
- if (tab[3][col+1]==min)
- {row=3;
- col++;}
- if (tab[row+1][col+1]==min)
- {row++;
- col++;}
- if (tab[row][col+1]==min)
- {row;
- col++;}
- printf("%d\t%d",row,col);}
- if ((row==1||row==2))
- {
- min=_Spr(tab[row-1][col+1],tab[row+1][col+1],tab[row][col+1]);
- if (tab[row-1][col+1]==min)
- {row--;
- col++;}
- if (tab[row+1][col+1]==min)
- {row++;
- col++;}
- if (tab[row][col+1]==min)
- {row;
- col++;}
- printf("%d\t%d",row,col);
- }
- //opcja po skosie w gore
- if (row==3)
- {
- min=_Spr(tab[row-1][col+1],tab[0][col+1],tab[row][col+1]);
- if (tab[row-1][col+1]==min)
- {row--;
- col++;}
- if (tab[0][col+1]==min)
- {row=0;
- col++;}
- if (tab[row][col+1]==min)
- {row;
- col++;}
- printf("%d\t %d",row,col);}
- return 1;
- }
- int main()
- {
- int tab[4][3]={{1,7,3},{4,5,6},{7,0,9},{9,2,1}};
- int i,j,n,m;
- for(i=0; i<4; i++)
- {
- for(j=0; j<3; j++)
- printf("%d ",tab[i][j]);
- printf("\n");
- }
- printf("\n\n%d",KrokKtorysieoplaca(4,3));
- return 0;}
Advertisement
Add Comment
Please, Sign In to add comment