fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int a[10][10],x,y,res;
  5. void nhap()
  6. {
  7. for(int i=1;i<=5;i++)
  8. {
  9. for(int j=1;j<=5;j++)
  10. {
  11. cin>>a[i][j];
  12. if(a[i][j]==1)
  13. {
  14. x=i;y=j;
  15. }
  16. }
  17. }
  18. }
  19. void giai()
  20. {
  21. res=abs(x-3)+abs(y-3);
  22. cout<<res;
  23. }
  24.  
  25. int main()
  26. {
  27. nhap();
  28. giai();
  29. }
  30.  
Success #stdin #stdout 0.01s 5264KB
stdin
0 0 0 0 0
0 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
stdout
3