C/C++

ПОМОГИТЕ ОЧЕНЬ СРОЧНО C++

// 1
#include <iostream>
#include <ctime>
using namespace std;
int main() {
int ar[50];
cout << "Enter a size of the array (no more than 50: ";
int size;
cin >> size;

srand(time(0));
for (int i = 0; i < size; ++i) {
ar[i] = rand() % 35 - 7;
cout << ar[i] << " ";
}
cout << "\n";

for (int i = 0; i < size; ++i) {
if (i % 2 == 0 || i % 3 == 0) ar[i] += ar[2];
cout << ar[i] << " ";
}
cout << "\n";
}

// 2
#include <iostream>
#include <numeric>
#include <ctime>
using namespace std;
int main() {
int ar[50];
cout << "Enter a size of the array (no more than 50: ";
int size;
cin >> size;
cout << "Enter the range from A to B separated by a space: ";
int a, b;
cin >> a >> b;

srand(time(0));
for (int i = 0; i < size; ++i) {
ar[i] = rand() % (b-a+1) + a;
cout << ar[i] << " ";
}
cout << "\n";

int ind = 0;
for (int i = 0; i < size; ++i)
if(ar[i] <= ar[ind]) ind = i;

cout << "Sum: " << accumulate(ar+ind+1, ar+size, 0) << "\n";
}

// 3
#include <iostream>
#include <ctime>
using namespace std;
int main() {
int ar[50];
cout << "Enter a size of the array (no more than 50: ";
int size;
cin >> size;

int ind = 0, cnt = 0;
srand(time(0));
for (int i = 0; i < size; ++i) {
cout << (ar[i] = rand() % 21 + 1) << " ";
if ((~ar[i] & 1) && (cnt++ < 2)) ind = i;
}
cout << "\n";

for (int i = ind; i+1< size; ++i) ar[i] = ar[i+1];

for (int i = 0; i < size; ++i) cout << ar[i] << " ";
cout << "\n";
}

// 4
#include <iostream>
#include <ctime>
using namespace std;
int main() {
int ar[51];
cout << "Enter a size of the array (no more than 50: ";
int size;
cin >> size;

srand(time(0));
for (int i = 0; i < size; ++i)
cout << (ar[i] = rand() % 21 + 1) << " ";
cout << "\n";

for (int i = size++; i > 3; --i) ar[i] = ar[i-1];
ar[3] = ar[0];
for (int i = 0; i < size; ++i) cout << ar[i] << " ";
cout << "\n";
}

// 5
#include <iostream>
#include <ctime>
using namespace std;
int main() {
int ar[51];
cout << "Enter a size of the array (no more than 50: ";
int size;
cin >> size;

srand(time(0));
for (int i = 0; i < size; ++i)
cout << (ar[i] = rand() % 31 - 15) << " ";
cout << "\n";

sort(ar, ar+size/2);
sort(ar+size/2, ar+size);

for (int i = 0; i < size; ++i) cout << ar[i] << " ";
cout << "\n";
}
СД
Сергей Долганов
6 243
Лучший ответ
5.

#include "iostream"
#include "iomanip"
#include "ctime"
#include "cstdlib"
#include "algorithm"
using namespace std;
int main(){
int n; srand(time(NULL));
cout<<"Enter the size of array: "; cin>>n;
int *a=new int[n];
for(int i=0;i< n;i++)a[i]=rand()%199-99;
for(int i=0;i< n;i++)cout<<setw(4)<<a[i]; cout<< endl;
sort(a,a+n/2); sort(a+n/2,a+n);
for(int i=0;i< n;i++)cout<<setw(4)<<a[i]; cout<< endl;}
Юрий Игнатов
Юрий Игнатов
75 926
1)
int arr[N];
for(int i = 0; i < N; i++)
{
if (arr[i] % 2 == 0 || arr[i] % 3 == 0)
    arr[i] += arr[2];
}
VB
Viktor Boyko
73 465
Михаил Зулкарнеев А какие библиотеки надо использовать?