Автор - Fernando20

Нужна помощь! C++
Разработать структуры, реализовать необходимый набор операций с объектами
структурного типа. Обеспечить чтение данных из файла. Написать тестирующую
функцию main

Само задание:

Определить структуру для представления треугольника координатами вершин на
плоскости. Обеспечить выполнение операций вычисления площади, периметра
треугольника, вычисления высот, а также определения вида треугольника

Ответ

Автор - lexa23072003

using namespace std;

struct Treugolnik

{

int x1, y1;

int x2, y2;

int x3, y3;

};

int main()

{

Treugolnik a1;

cin >> a1.x1;

cin >> a1.x2;

cin >> a1.x3;

cin >> a1.y1;

cin >> a1.y2;

cin >> a1.y3;

float S, P, h,p;

 P = sqrt(pow(a1.x2 - a1.x1, 2) + pow(a1.y2 - a1.y1, 2))+sqrt(pow(a1.x3 - a1.x2, 2) + pow(a1.y3 - a1.y2, 2))+ sqrt(pow(a1.x3 - a1.x1, 2) + pow(a1.y3 - a1.y1, 2));

 p = 0.5*(sqrt(pow(a1.x2 - a1.x1, 2) + pow(a1.y2 - a1.y1, 2)) + sqrt(pow(a1.x3 - a1.x2, 2) + pow(a1.y3 - a1.y2, 2)) + sqrt(pow(a1.x3 - a1.x1, 2) + pow(a1.y3 - a1.y1, 2)));

 S = sqrt(p*(p - sqrt(pow(a1.x2 - a1.x1, 2) + pow(a1.y2 - a1.y1, 2))))*(p - sqrt(pow(a1.x3 - a1.x2, 2) + pow(a1.y3 - a1.y2, 2)))*(p - sqrt(pow(a1.x3 - a1.x1, 2) + pow(a1.y3 - a1.y1, 2)));

 h = 2 * S / sqrt(pow(a1.x2 - a1.x1, 2) + pow(a1.y2 - a1.y1, 2)); //// только к одной стороне  

 if (sqrt(pow(a1.x2 - a1.x1, 2) + pow(a1.y2 - a1.y1, 2)) == sqrt(pow(a1.x3 - a1.x2, 2) + pow(a1.y3 - a1.y2, 2)) == sqrt(pow(a1.x3 - a1.x1, 2) + pow(a1.y3 - a1.y1, 2)))

  cout << "ранвостронний";

 if (pow(sqrt(pow(a1.x2 - a1.x1, 2) + pow(a1.y2 - a1.y1, 2)), 2)+pow(sqrt(pow(a1.x3 - a1.x2, 2) + pow(a1.y3 - a1.y2, 2)),2)==pow(sqrt(pow(a1.x3 - a1.x1, 2) + pow(a1.y3 - a1.y1, 2)),2));

 cout << "прямоугольный";

 cout << S;

 cout << h;

 cout << P;

 return 0;

}

Ответы и объяснения

Сервис носит ознакомительный характер, вся информация, а в частности вопросы и ответы, которые задают и отвечают пользователи.
© 2026 Все права защищены Политика конфиденциальности Контакты
search points attachment profile arrow left arrow right star heart verified symbols equation arrow-down question mark check menu accountancyadministrationagriculturalalgebraallarabicartart_musicbelarusbelarus_altbiologybusinesscatalachemistrychineseeconomicsegzamenglishentrepreneurshipenvironmentethicseuskarafirst_aidfrenchgalegogeographygeologygeometrygermangrammarhealthhistoryindia_langindonesian_langinformaticsitalianjapanesekazachkazach_altkoreanlanguagelatinlawlife_scienceliteraturelogicmathematicsmusicnigerian_langother_languagesotherspedagogicsphilosophyphysical_educationphysicspoliticspsychologyreligionrpa_langrussianrussian_altsciencesecurityskillssocial_sciencesociologyspanishstatisticstechnologytourismtrafficukrainianukrainian_altukrainian_literaturewos_civilisation accountancyadministrationagriculturalalgebraall_1arabicartart_music_2belarusbelarus_altbiologybusiness_2catalachemistry_1chineseeconomicsexam_3englishentrepreneurshipenvironment_2ethicseuskarasecurity_1frenchgalegogeography_4geology_4geometrygermangrammarhealthhistoryindia-langindonesian-langinformaticsitalianjapanesekazachAsset 230koreanlanguagelatinlawlife-scienceliteraturelogic_2mathematicsmusicnigerian-langotherlanguagesother_1pedagogicsphilosophyphysical_educationphysicspoliticspsychologyreligion_1rpa-langrussianrussian_altsciencesecurity_3_mskills_1allsocial_science_5_msociologyspanishstatisticstechnologytourismtrafficukrainianukrainian_altukrainian_literaturewos_civilisation