Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int m,n;
- scanf("%d%d",&n,&m);
- int mat[n][m];
- for(int i=0;i<n;i++)
- for(int j=0;j<m;j++)
- scanf("%d",&mat[i][j]);
- int x,xj;
- scanf("%d%d",&x,&xj);
- if(mat[x][xj]==1){
- for(int i=0;i<n;i++){
- for(int j=0;j<m;j++){
- printf("%d ", mat[i][j]);
- }
- printf("\n");
- }
- }
- else{
- mat[x][xj] = 1;
- for(int j=xj+1;j<m;j++) // desno od elemenot
- if(mat[x][j]==1){
- break;
- }
- else{
- mat[x][j]=1;
- }
- for(int j=xj-1;j>=0;j--) // levo od elementot
- if(mat[x][j]==1){
- break;
- }
- else{
- mat[x][j]=1;
- }
- for(int i=x+1;i<n;i++) // dole od elementot
- if(mat[i][xj]==1){
- break;
- }
- else{
- mat[i][xj]=1;
- }
- for(int i=x-1;i>=0;i--) // gore od elemento
- if(mat[i][xj]==1){
- break;
- }
- else{
- mat[i][xj]=1;
- }
- for(int i=0;i<n;i++){
- for(int j=0;j<m;j++){
- printf("%d ", mat[i][j]);
- }
- printf("\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment