Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int N, m[101][101];
- cin>>N;
- for (int i = 1; i <= N; ++i)
- for (int j = 1; j <= N; ++j)
- cin>>m[i][j];
- // parcurgem fiecare element de pe prima linie
- for (int j = N; j >= 1; --j) {
- int linie = 1, coloana = j;
- // parcurgem paralela la diagonala
- while (linie <= N && coloana <= N) {
- cout<<m[linie][coloana]<<' ';
- ++linie;
- ++coloana;
- }
- cout<<'\n';
- }
- // parcurgem fiecare element de pe prima coloana
- for (int i = 2; i <= N; ++i) {
- int linie = i, coloana = 1;
- // parcurgem paralela la diagonala
- while (linie <= N && coloana <= N) {
- cout<<m[linie][coloana]<<' ';
- ++linie;
- ++coloana;
- }
- cout<<'\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement