Джина0
20.11.2020 17:36

3.Переписать массив D = (1 2 3 4 5 6 7 8 9 10) в обратном порядке (использовать циклы).
4. Напишите программу, с которой можно вычислить площадь
треугольника S по формуле Герона (площадь треугольника по трем
сторонам).

Нажмите на рекламу ниже и сразу увидите ответ
Популярные вопросы:
Ответ:
katyapugachewa
13.12.2022 05:11
#include "math.h"
#include <iostream>
using namespace std;
int main()
{
//объявление переменных
float xa, ya, xb, yb, ab ;
//ввод переменных 
cout<<"Vvedite xa: "<<endl;
cin>>xa;
cout<<"Vvedite ya: "<<endl;
cin>>ya;
cout<<"Vvedite xb: "<<endl;
cin>>xb;
cout<<"Vvedite yb: "<<endl;
cin>>yb;
//расчет длинны отрезка
ab=sqrt(pow(xa-xb,2)+pow(ya-yb,2);
//вывод длины отрезка
cout<<"|AB| = "<<ab<<endl;
system("pause");
return 0;
}
0,0(0 оценок)
Ответ:
Никас111
23.03.2023 00:55

random_device rd;

mt19937 eng(rd());

uniform_int_distribution<int> dist(1, 10);

 

int n;

int x;

cin >> n >> x;

 

vector<int> a(n);

for (auto& i : a)

 i = dist(eng);

 

copy(a.cbegin(), a.cend(), ostream_iterator<int>(cout, " "));

 

cout << '\n';

 

sort(a.begin(), a.end());

 

copy(a.cbegin(), a.cend(), ostream_iterator<int>(cout, " "));

 

cout << '\n';

 

if (binary_search(a.cbegin(), a.cend(), x)) {

 cout << x << " found";

} else {

 set<int> temp(a.cbegin(), a.cend());

 

 if (x < *temp.cbegin()) {

   cout << *temp.cbegin();

 } else if (x > *prev(temp.cend())) {

   cout << *prev(temp.cend());

 } else {

   auto f = lower_bound(a.cbegin(), a.cend(), x);

   auto s = upper_bound(a.cbegin(), a.cend(), x);

 

   if (f != a.cend() && s != a.cend()) {

     if (abs(*f - x) < abs(*s - x)) {

       cout << *f;

     } else {

       cout << *s;

     }

   } else if (f == a.cend() && s != a.cend()) {

     cout << *s;

   } else if (f != a.cend() && s == a.cend()) {

     cout << *f;

   }

 }

}

0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота