#include <iostream>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
vector< vector<int> > arr;
arr.resize(8);
for (int i = 0; i < 8; ++i) {
arr[i].resize(7);
}
for (int j = 0; j < 7; ++j) {
arr[i][j] = rand();
cout << arr[i][j] << " ";
if (j == 6) {
cout << endl;
swap(arr[3], arr[0]);
swap(arr[4], arr[7]);
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
vector< vector<int> > arr;
arr.resize(8);
for (int i = 0; i < 8; ++i) {
arr[i].resize(7);
}
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 7; ++j) {
arr[i][j] = rand();
cout << arr[i][j] << " ";
if (j == 6) {
cout << endl;
}
}
}
swap(arr[3], arr[0]);
swap(arr[4], arr[7]);
cout << endl;
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 7; ++j) {
cout << arr[i][j] << " ";
if (j == 6) {
cout << endl;
}
}
}
}