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

1 семестр / лр 4

.docx
Скачиваний:
35
Добавлен:
16.12.2020
Размер:
42.95 Кб
Скачать

Учреждение образования

«БЕЛОРУССКИЙ ГОСУДАРСТВЕННЫЙТЕХНОЛОГИЧЕСКИЙ УНИВЕРСИТЕТ»

Кафедра информационных систем и технологий

ОТЧЕТ

по лабораторной работе №4

Ввод и вывод информации

Выполнила: студентка ФИТ группы № 9 Каленик Алина

Проверила: Пустовалова Наталья Николаевна

Минск 2020

Задание №1

3

1. Нарисовать елочку, закрашенную введенным символом.

#include <iostream>

#include <iomanip>

using namespace std;

void main()

{

setlocale(LC_CTYPE, "Russian");

char s, probel;

probel = ' ';

cout << "Введите желаемый символ " << endl;

cin >> s;

cout << setw(10) << setfill(probel) << probel;

cout << setw(2) << setfill(s) << s << endl;

cout << setw(10) << setfill(probel) << probel;

cout << setw(2) << setfill(s) << s << endl;

cout << setw(8) << setfill(probel) << probel;

cout << setw(6) << setfill(s) << s << endl;

cout << setw(8) << setfill(probel) << probel;

cout << setw(6) << setfill(s) << s << endl;

cout << setw(6) << setfill(probel) << probel;

cout << setw(10) << setfill(s) << s << endl;

cout << setw(6) << setfill(probel) << probel;

cout << setw(10) << setfill(s) << s << endl;

cout << setw(4) << setfill(probel) << probel;

cout << setw(14) << setfill(s) << s << endl;

cout << setw(4) << setfill(probel) << probel;

cout << setw(14) << setfill(s) << s << endl;

cout << setw(10) << setfill(probel) << probel;

cout << setw(2) << setfill(s) << s << endl;

cout << setw(10) << setfill(probel) << probel;

system("pause");

}

#include <stdio.h>

#include <iostream>

void main()

{

char s, probel;

probel = ' ';

setlocale(LC_CTYPE, "Russian");

printf("Введите желаемый символ\n");

scanf_s("%c", &s);

printf("%c%c%c%c%c%c%c%c%c%c", probel, probel, probel, probel, probel, probel, probel, probel, probel, probel);

printf("%c%c\n", s, s);

printf("%c%c%c%c%c%c%c%c%c%c", probel, probel, probel, probel, probel, probel, probel, probel, probel, probel);

printf("%c%c\n", s, s);

printf("%c%c%c%c%c%c%c%c", probel, probel, probel, probel, probel, probel, probel, probel);

printf("%c%c%c%c%c%c\n", s, s, s, s, s, s);

printf("%c%c%c%c%c%c%c%c", probel, probel, probel, probel, probel, probel, probel, probel);

printf("%c%c%c%c%c%\n", s, s, s, s, s, s);

printf("%c%c%c%c%c%c", probel, probel, probel, probel, probel, probel);

printf("%c%c%c%c%c%c%c%c%c%c\n", s, s, s, s, s, s, s, s, s, s);

printf("%c%c%c%c%c%c", probel, probel, probel, probel, probel, probel);

printf("%c%c%c%c%c%c%c%c%c%c\n", s, s, s, s, s, s, s, s, s, s);

printf("%c%c%c%c", probel, probel, probel, probel);

printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n", s, s, s, s, s, s, s, s, s, s, s, s, s, s);

printf("%c%c%c%c", probel, probel, probel, probel);

printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n", s, s, s, s, s, s, s, s, s, s, s, s, s, s);

printf("%c%c%c%c%c%c%c%c%c%c", probel, probel, probel, probel, probel, probel, probel, probel, probel, probel);

printf("%c%c\n", s, s);

}

Задание №2

3

2. Поменять значения двух переменных: а) используя дополнительную переменную; б) не используя дополнительной переменной.

a) #include <iostream>

using namespace std;

int main()

{

setlocale(LC_CTYPE, "Russian");

double a, b, c;

cout << "Введите число a" << endl;

cin >> a;

cout << "Введите число b" << endl;

cin >> b;

c = a;

a = b;

b = c;

cout << "a = " << a << endl;

cout << "b = " << b << endl;

}

б) #include <iostream>

using namespace std;

int main()

{

setlocale(LC_CTYPE, "Russian");

double a, b;

cout << "Введите число a" << endl;

cin >> a;

cout << "Введите число b" << endl;

cin >> b;

a = a + b;

b = a - b;

a = a - b;

cout << "a = " << a << endl;

cout << "b = " << b << endl;

}

a) #include <iostream>

int main()

{

setlocale(LC_CTYPE, "Russian");

double a, b;

printf("Введите число a\n");

scanf_s("%d", &a);

printf("Введите число b\n");

scanf_s("%d", &b);

a = a + b;

b = a - b;

a = a - b;

printf("a = %d\n", a);

printf("b = %d\n", b);

}

б) #include <iostream>

int main()

{

setlocale(LC_CTYPE, "Russian");

double a, b, c;

printf("Введите число a\n");

scanf_s("%d", &a);

printf("Введите число b\n");

scanf_s("%d", &b);

c = a;

a = b;

b = c;

printf("a = %d\n", a);

printf("b = %d\n", b);

}

Задание №2

3

2. Даны числа X, Y, Z. Определить среднее арифметическое и среднее геометрическое их модулей.

#include <iostream>

using namespace std;

void main()

{

setlocale(LC_ALL, "rus");

double x, y, z, m, n;

cout << "Введите число x" << endl;

cin >> x;

cout << "Введите число y" << endl;

cin >> y;

cout << "Введите число z" << endl;

cin >> z;

m = (abs(x) + abs(y) + abs(z)) / 3;

n = sqrt(abs(x) * abs(y) * abs(z));

cout << "Среднее арифметическое введенных чисел = " << m << endl;

cout << "Среднее геометрическое введенных чисел = " << n << endl;

}

#include <iostream>

using namespace std;

void main()

{

setlocale(LC_ALL, "rus");

double x, y, z, m, n, a, b, c;

cout << "Введите число x" << endl;

cin >> x;

cout << "Введите число y" << endl;

cin >> y;

cout << "Введите число z" << endl;

cin >> z;

a = abs(x);

b = abs(y);

c = abs(z);

m = (a + b + c) / 3;

n = sqrt(a * b * c);

cout << "Среднее арифметическое введенных чисел = " << m << endl;

cout << "Среднее геометрическое введенных чисел = " << n << endl;

}

#include <iostream>

#include <stdio.h>

void main()

{

setlocale(LC_ALL, "rus");

float x, y, z, m, n;

printf("Введите число x\n");

scanf_s("%f", &x);

printf("Введите число y\n");

scanf_s("%f", &y);

printf("Введите число z\n");

scanf_s("%f", &z);

m = (abs(x) + abs(y) + abs(z)) / 3;

n = sqrt(abs(x) * abs(y) * abs(z));

printf("Среднее арифметическое введенных чисел = %f\n", m);

printf("Среднее геометрическое введенных чисел = %f\n", n);

}

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