Объяснение:
#include <iostream>
using namespace std;
int main()
{
//1 - 2 задания
setlocale(LC_ALL, "Russian");
system("color A");
int A,a;
cout << "Введите число: ";
cin >> a;
while (a--)
cout << a << ' ';
cout << endl;
//2
cin >> A;
A -= !(A & 1) + 2;
while ((A += 2) < 1000)
cout << A << ' ';
}
//
//3 задание
for (int i = 1; i < 10; i += 2)
cout << i * i << ' ';
int main() {
int arr[100], n, first = 0, second = 0;
std::cin >> n;
for (int i = 0; i < n; ++i)
std::cin >> arr[i];
for (int i = 1; i < n; ++i) {
const int diff = arr[i] - arr[i - 1];
if (diff > 0)
if (arr[i] <= 2000)
first += diff;
else if (arr[i - 1] >= 2000)
second += diff;
else {
first += 2000 - arr[i - 1];
second += arr[i] - 2000;
std::cout << first << ' ' << second;
return 0;
язык python
Объяснение:
#include <iostream>
using namespace std;
int main()
{
//1 - 2 задания
setlocale(LC_ALL, "Russian");
system("color A");
int A,a;
cout << "Введите число: ";
cin >> a;
while (a--)
cout << a << ' ';
cout << endl;
//2
cout << "Введите число: ";
cin >> A;
A -= !(A & 1) + 2;
while ((A += 2) < 1000)
{
cout << A << ' ';
}
}
//
//3 задание
#include <iostream>
using namespace std;
int main()
{
for (int i = 1; i < 10; i += 2)
cout << i * i << ' ';
}
#include <iostream>
int main() {
int arr[100], n, first = 0, second = 0;
std::cin >> n;
for (int i = 0; i < n; ++i)
std::cin >> arr[i];
for (int i = 1; i < n; ++i) {
const int diff = arr[i] - arr[i - 1];
if (diff > 0)
if (arr[i] <= 2000)
first += diff;
else if (arr[i - 1] >= 2000)
second += diff;
else {
first += 2000 - arr[i - 1];
second += arr[i] - 2000;
}
}
std::cout << first << ' ' << second;
return 0;
Объяснение:
язык python