题解 | #箱子归位#

箱子归位

https://ac.nowcoder.com/acm/problem/22212

using namespace std;
#define int long long
#define endl '\n'
signed main(){
    std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a[5][5];int x,y;
    for(int i=0;i<5;i++)
    {
        for(int j=0;j<5;j++){
            cin>>a[i][j];
            if(a[i][j]==1)x=i,y=j;
        }
    }
    int s1,s2;
    s1=x-2;s2=y-2;
    if(x<2)s1=-s1;
    if(y<2)s2=-s2;//因为不知道绝对值的函数,所以这样写了,可以直接用abs(x-2)
    cout<<s1+s2<<endl;
    return 0;
}
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务