Created
October 31, 2020 09:02
-
-
Save riku179/2c5df81966dd703eae3056ce88b8d539 to your computer and use it in GitHub Desktop.
行列の斜め走査
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() { | |
int N, M; | |
cin >> N >> M; | |
for (int s=0; s<N+M-1; s++) { | |
int i, j; | |
if (s < N) { | |
i=s, j=0; | |
} else { | |
i=N-1; j=s-i; | |
} | |
for (; i >= 0 && j < M; i--, j++) { | |
// here | |
cout << i << ' ' << j << endl; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ex) N=4, M=5