Задание 1:
using namespace std;
#include <iostream>
#include <clocale>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <ctime>
int main() {
setlocale(LC_ALL, "rus");
system("chcp 1251");
srand(time(0));
int N = rand() % 6 + 5;
int pos = 0, neg = 0, max = -20, min = 20, maxind, minind;
int* mass = new int[N];
cout << "Массив:" << endl;
for (int i = 0; i < N; i++) {
mass[i] = rand() % 41 - 20;
if (mass[i] > 0) pos++;
if (mass[i] < 0) neg++;
if (mass[i] > max) {
max = mass[i];
maxind = i;
}
if (mass[i] < min) {
min = mass[i];
minind = i;
}
cout << setw(3) << mass[i];
}
cout << endl << endl;
if (pos > neg) {
swap(mass[maxind], mass[minind]);
cout << "Измененный массив:" << endl;
for (int i = 0; i < N; i++) {
cout << setw(3) << mass[i];
}
}
else cout << "Массив не изменился";
cout << endl;
delete[] mass;
system("pause");
return 0;
}
Задание 2:
using namespace std;
#include <iostream>
#include <clocale>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <ctime>
int main() {
setlocale(LC_ALL, "rus");
system("chcp 1251");
srand(time(0));
int N = rand() % 6 + 5;
int max = -20, min = 20, maxind, minind;
int* mass = new int[N];
cout << "Массив:" << endl;
for (int i = 0; i < N; i++) {
mass[i] = rand() % 41 - 20;
if (mass[i] > max) {
max = mass[i];
maxind = i;
}
if (mass[i] < min) {
min = mass[i];
minind = i;
}
cout << setw(3) << mass[i];
}
cout << endl << endl;
if (abs(minind - maxind) == 1) {
cout << "Измененный массив:" << endl;
for (int i = 0; i < N; i++) {
if (mass[i] < 0) mass[i] = 0;
cout << setw(3) << mass[i];
}
}
else cout << "Массив не изменился";
cout << endl;
delete[] mass;
system("pause");
return 0;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style type="text/css">
#circle {
border-radius: 100px;
width: 100px;
height: 100px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
cursor: pointer;
}
#circle.red {
background-color: red;
}
#circle.green {
background-color: green;
}
#circle.orange {
background-color: orange;
}
</style>
<title>Title</title>
</head>
<body>
<div id="circle" class="red"></div>
<скрипт>
colors = ["red", "green", "orange"]
document.getElementById("circle").addEventListener("click", function(e) {
const element = this;
let currentColor = element.classList.value
if (currentColor === "orange"){
currentColor = colors[0]
} else {
currentColor = colors[colors.indexOf(currentColor)+1]
}
element.classList = currentColor
})
</скрипт>
</body>
</html>
P.S. При загрузке фулл кода выдает ошибку от сайта.. Поэтому на фотке весь код