Skip to content

Instantly share code, notes, and snippets.

@lazycipher
Created August 9, 2019 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazycipher/e7d1ce2c43b109e5800f55b2a6cb2841 to your computer and use it in GitHub Desktop.
Save lazycipher/e7d1ce2c43b109e5800f55b2a6cb2841 to your computer and use it in GitHub Desktop.
263A - Beautiful Matrix Solution in CPP
#include<iostream>
int main(){
int arr[5][5];
int x,y;
for(int i=0; i<5; i++){
for(int j=0; j<5; j++){
std::cin>>arr[i][j];
if(arr[i][j]!=0){
x=i+1;
y=j+1;
}
}
}
std::cout<<abs(x-3)+abs(y-3);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment