题解 | #二维数组操作#

二维数组操作

https://www.nowcoder.com/practice/2f8c17bec47e416897ce4b9aa560b7f4

#include <stdio.h>

int main() {
    int a, b;
    int m,n,x1,x2,y1,y2,x,y,x3,y3,t;
   
    for(t=1;t<=5;t++)
    {
        m=n=x1=x2=y1=y2=x=y=x3=y3=0;
        if(scanf("%d",&m)!=EOF)
            scanf("%d",&n);
        else break;
        if(m<=0||m>9||n<=0||n>9)
        printf("-1\n");
        else printf("0\n");
        m=m-1;n=n-1;

        scanf("%d",&x1);scanf("%d",&y1);scanf("%d",&x2);scanf("%d",&y2);
        if(x1<=m&&x2<=m&&y1<=n&&y2<=n)
        printf("0\n");
        else printf("-1\n");

        scanf("%d",&x);scanf("%d",&y);
         if(x<=m&&x>=0&&(m+1)<9)
         {
            printf("0\n");
            m=m;
         }
        else printf("-1\n");
         if(y<=n&&y>=0&&(n+1)<9)
         {
            printf("0\n");
            n=n;
         }
        else printf("-1\n");
        scanf("%d",&x3);scanf("%d",&y3);
        if(x3<0||x3>m||y3<0||y3>n)
        printf("-1\n");
        else printf("0\n");
    }
    
    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享
牛客网
牛客企业服务