#include <iostream>
#include <vector>
#include <random>
using namespace std;
signed main(){
srand(time(NULL));
const int n = 10;
vector<int> a(n);
for(int i = 0; i < n; i++){
a[i] = rand() % 99 + 1;
cout << a[i] << " ";
}
cout << "\n";
for(int i = 1; i < n; i+=2){
swap(a[i], a[i-1]);
cout << a[i-1] << " " << a[i] << " ";
Объяснение:
Сделай лучший ответ
#include <iostream>
#include <vector>
#include <random>
using namespace std;
signed main(){
srand(time(NULL));
const int n = 10;
vector<int> a(n);
for(int i = 0; i < n; i++){
a[i] = rand() % 99 + 1;
cout << a[i] << " ";
}
cout << "\n";
for(int i = 1; i < n; i+=2){
swap(a[i], a[i-1]);
cout << a[i-1] << " " << a[i] << " ";
}
}
Объяснение:
#include <iostream>
#include <vector>
#include <random>
using namespace std;
signed main(){
srand(time(NULL));
const int n = 10;
vector<int> a(n);
for(int i = 0; i < n; i++){
a[i] = rand() % 99 + 1;
cout << a[i] << " ";
cout << "\n";
for(int i = 1; i < n; i+=2){
swap(a[i], a[i-1]);
cout << a[i-1] << " " << a[i] << " ";
Сделай лучший ответ