Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <algorithm>
- #include <cmath>
- using namespace std;
- int main()
- {
- int n, t, m;
- t = 0;
- cin >> n >> m;
- int **a = new int *[n];
- for (int i = 0; i < n; i++) {
- a[i] = new int[m];
- }
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- cin >> *(*(a + i) + j);
- }
- }
- int *b;
- if (n % 2 == 0) {
- for (int i = 0; i < n; i+=2) {
- b = a[i];
- a[i] = a[i+1];
- a[i+1] = b;
- }
- }
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- cout << a[i][j] << " ";
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement