Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Zhovtyak lab 5

.docx
Скачиваний:
0
Добавлен:
27.08.2024
Размер:
155.82 Кб
Скачать

ГУАП

КАФЕДРА № 41

ОТЧЕТ ЗАЩИЩЕН С ОЦЕНКОЙ

ПРЕПОДАВАТЕЛЬ

должность, уч. степень, звание

подпись, дата

инициалы, фамилия

ОТЧЕТ О ЛАБОРАТОРНОЙ РАБОТЕ

ФУНКЦИИ

по курсу: ИНФОРМАТИКА

РАБОТУ ВЫПОЛНИЛ

СТУДЕНТ ГР. №

4016

М.О.Жовтяк

подпись, дата

инициалы, фамилия

Санкт-Петербург 2020

Цель работы: освоение принципов декомпозиции программы на подпрограммы, изучение синтаксиса определения и вызова функций в языке С++, совершенствование навыков разработки и откладки программ в IDE.

Мой индивидуальный вариант:

Задача заключается в том, чтобы решить задачу, используя функцию и вызвав ее в программе.

Мой код:

#include <iostream>

#include <cmath>

using namespace std;

int ax, ay, bx, by, cx, cy, res, res1, res2, res3;

int composition(int a1, int a2,int a3,int a4) {

res = (a1 *a2) + (a3 * a4);

return res;

}

int main()

{

cout << "This program helps you to find the biggest scalar composition of three pairs of vectors" << endl;

cout << "Insert the x - coordinate of the first vector" << endl;

cin >> ax;

cout << "Insert the y - coordinate of the first vector" << endl;

cin >> ay;

cout << "Insert the x - coordinate of the second vector" << endl;

cin >> bx;

cout << "Insert the y - coordinate of the second vector" << endl;

cin >> by;

cout << "Insert the x - coordinate of the third vector" << endl;

cin >> cx;

cout << "Insert the y - coordinate of the third vector" << endl;

cin >> cy;

res1 = composition(ax, bx, ay, by); //first composition

res2 = composition(cx, bx, cy, by); //second composition

res3 = composition(ax, cx, ay, cy); //third composition

if (res1 > res2) {

if (res1 > res3) {

cout << "Composition of the first and the second vectors is the biggest = " << res1;

}

else cout << "Composition of the first and the third vectors is the biggest = " << res3;

}

else if (res2 > res3) {

cout << "Composition of the second and the third vectors is the biggest = " << res2;

}

else cout << "Composition of the first and the third vectors is the biggest = " << res3;

}

Итак, результаты моей работы:

Предлагаю выполнить проверку работы на листе бумаги:

Ответ вышел верным, значит программа работает корректно.

Вывод: в этой лабораторной работе я научился вводить и вызывать функции, освоил принципы декомпозиции программы над подпрограммы.

Соседние файлы в предмете Информатика