#include <iostream>using std::cout;using std::endl;#include <cstdlib>using std::rand;using std::srand;#include <ctime>using std::time;int main(){ int a[10]; srand(time(0)); for(int i = 0; i < 10; i++) { a[i] = rand() % 201 - 100; cout << a[i] << ' '; } cout << endl; int temp; for(int i = 0; i < 5; i++) { temp = a[i]; a[i] = a[i + 5]; a[i + 5] = temp; } for(int i = 0; i < 10; i++) { cout << a[i] << ' '; } cout << endl; return 0;}
#include <iostream>
using std::cout;
using std::endl;
#include <cstdlib>
using std::rand;
using std::srand;
#include <ctime>
using std::time;
int main()
{
int a[10];
srand(time(0));
for(int i = 0; i < 10; i++)
{
a[i] = rand() % 201 - 100;
cout << a[i] << ' ';
}
cout << endl;
int temp;
for(int i = 0; i < 5; i++)
{
temp = a[i];
a[i] = a[i + 5];
a[i + 5] = temp;
}
for(int i = 0; i < 10; i++)
{
cout << a[i] << ' ';
}
cout << endl;
return 0;
}