fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int arr[5][5];
  8. // entring the array
  9. for (int i =0 ; i < 5; i++)
  10. {
  11. for(int j=0; j < 5; j++)
  12. {
  13. cin >> arr[i][j];
  14. }
  15. }
  16. int x =0;
  17. int y =0;
  18.  
  19. // finding the cordinates of the one
  20. for (int i =0 ; i < 5; i++)
  21. {
  22. for(int j=0; j < 5; j++)
  23. {
  24. if (arr[i][j] == 1)
  25. {
  26. x =i;
  27. y =j;
  28. }
  29. }
  30. }
  31. cout << (abs(x-2) + abs(y-2));
  32. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
4