题解 | #二维数组操作#

二维数组操作

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

// HJ83-2 二维数组操作.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
#include<iostream>
#include<bits/stdc++.h>

using namespace std;

int main()
{
	int m, n,x1,y1,x2,y2,xc,yc,xf,yf;
	while (cin >> m >> n)
	{
		if (m > 9 || n > 9)
		{
			cout << "-1" << endl;
		}
		else
			cout << "0" << endl;
		cin >> x1 >> y1 >> x2 >> y2;
		if (x1 > (m - 1) || y1 > (n - 1) || x2 > (m - 1) || y2 > (n - 1))
		{
			cout << "-1" << endl;
		}
		else
			cout << "0" << endl;
		cin >> xc;
		if (m == 9||xc>(m-1))
		{
			cout << "-1" << endl;
		}
		else
			cout << "0" << endl;
		cin >> yc;
		if (n == 9||yc>(n-1))
		{
			cout << "-1" << endl;
		}
		else
			cout << "0" << endl;
		cin >> xf>>yf;
		if (xf > (m - 1)|| yf > (n - 1))
		{
			cout << "-1" << endl;
		}
		else
			cout << "0" << endl;
	}
	return 0;
}

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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