федя666
11.07.2020 09:08

Можете кто-нибудь сделать СОР по информатике​


Можете кто-нибудь сделать СОР по информатике​

Нажмите на рекламу ниже и сразу увидите ответ
Популярные вопросы:
Ответ:
Franker10
21.07.2020 20:36
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x64

#include <array>
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;

int main()
{
    array<array<int, 3>, 3> arr2d { { { 5, 4, 0 },
                                      {-3, 5, 7 },
                                      { 8, 2,-1 } } };
    pair<int, int> maxmin(INT_MAX, 0);
    for (const auto& i : arr2d)
   {
        int curr_min  = *min_element(i.cbegin(), i.cend());
        int curr_max  = *max_element(i.cbegin(), i.cend());
        maxmin.first  = maxmin.first > curr_min ? curr_min : maxmin.first;
        maxmin.second = maxmin.second < curr_max ? curr_max :
maxmin.second;
    }
    cout << maxmin.first << " " << maxmin.second;
}
0,0(0 оценок)
Ответ:
radvika08
10.09.2022 11:17
#include <iostream>
#include <random>
#include <ctime>
using namespace std;

mt19937 gen(time(0));
uniform_int_distribution<> uid(0, 19);
void replace(int *a, int n, int k)
{
int last = a[n];
for (int i = n - 1; i >= k; i--) {
a[i + 1] = a[i];
}
a[k] = last;
}

int main()
{
int n = 0, k = 0;
cin >> n;
int *a = new int[n];
if (n <= 100) {
 for (int i = 0; i <= n; i++) {
  a[i] = uid(gen); cout << a[i] << " ";
 }
 cout << endl; cin >> k;
 if (k <= n) {
  replace(a, n, k - 1);
  for (int i = 0; i <= n; i++) {
   cout << a[i] << " "; }
 } else {
  cout << "Error" << endl;
 }
} else {
 cout << "Error!" << endl;
}
delete[] a;
return 0;
}
0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота