zoj 1414 题目解答:zoj 的 1414 题该怎么解答呢?有什么方法呢?希望下面的文章对大家有所帮助。
如图所示:
给一个坐标,输出对应的数字
解题思路:
找规律就行了
代码如下:
- #includeint main() {
- int n,
- x,
- y,
- i,
- num;
- scanf("%d", &n);
- for (i = 1; i <= n; i++) {
- scanf("%d%d", &x, &y);
- if ((x != y) && ((x - y) != 2)) printf("No Number\n");
- else if (x == y) if ((x + y) % 4 == 0) {
- num = x + y;
- printf("%d\n", num);
- } else {
- num = 1 + 4 * ((x + y) / 4);
- printf("%d\n", num);
- } else if ((x - y) == 2) if ((x + y) % 4 != 0) {
- num = 2 + 4 * ((x + y) / 4);
- printf("%d\n", num);
- } else {
- num = x + y - 1;
- printf("%d\n", num);
- }
- }
- return 0;
- }
就爱阅读 www.92to.com 网友整理上传, 为您提供最全的知识大全, 期待您的分享,转载请注明出处。
来源: