Demo entry 3548939

10252

   

Submitted by anonymous on Jan 20, 2016 at 11:14
Language: C++. Code size: 700 Bytes.

#include <stdio.h>
#include <iostream>
#pragma warning(disable:4996)

void printMat(int m, int n) {
	printf("(%d,%d)\n", m,n);
}
int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	int T=0,m=0,n=0;
	std::cin >> T;
	for (int i = 0; i < T; ++i) {
		std::cin >> m >> n;
		std::cout << "1" << std::endl;
		for (int j = 0; j < n; ++j) {
			printMat(0, j);
		}
		for (int j = 1; j < m; ++j) {
			printMat(j, n - 1);
		}
		for (int j = n-2; j>=0; --j) {
			if ((j-n+2) % 2) {		// 짝수번쨰 시행
				for (int k = 1; k < m; ++k) {
					printMat(k, j);
				}
			}
			else {				// 홀수번째 시행
				for (int k = m-1; k > 0; --k) {
					printMat(k, j);
				}
			}
		}
	}
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).