Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Общий отчет - Назаренко (26-а).docx
Скачиваний:
0
Добавлен:
01.05.2025
Размер:
1.01 Mб
Скачать

Завдання №7

Листинг программы:

#include "stdafx.h"

#include <iostream>

#include <locale>

#include <fstream>

using namespace std;

struct NOTE

{

char p[1][80],i[1][80];

char t[1][12];

char m[1][2];

char d[1][2];

char g[1][4];

};

void add(NOTE note1)

{

ofstream out("note.txt", ios::out | ios::app);

cout<<"Введите фамилию: ";

cin>>note1.p[0];

out<<note1.p[0]<<" ";

cout<<"Введите имя: ";

cin>>note1.i[0];

out<<note1.i[0]<<" ";

cout<<"Введите телефон (380...)";

cin>>note1.t[0];

out<<note1.t[0]<<" ";

cout<<"Введите дату рождения(ММ ДД ГГ):";

cin>>note1.m[0];

out<<note1.m[0]<<" ";

cin>>note1.d[0];

out<<note1.d[0]<<" ";

cin>>note1.g[0];

out<<note1.g[0]<<endl;

out.close();

cout<<endl;

system("pause");

system("cls");

};

void showd(NOTE note1)

{

char mas[8][80];

ifstream in("note.txt");

char x[1][2];

cout<<"Введите месяц рождения: ";

cin>>x[0];

cout<<endl;

while (!in.eof())

{

for (int i=0;i<1;i++)

{

in>>note1.p[0];

in>>note1.i[0];

in>>note1.t[0];

in>>note1.m[0];

in>>note1.d[0];

in>>note1.g[0];

if (note1.m[0][0]==x[0][0] && note1.m[0][1]==x[0][1])

{ cout<<note1.p[0]<<" "<<note1.i[0]<<" ";

for (int i=0;i<12;i++)

cout<<note1.t[0][i];

cout<<" "<<note1.m[0][0]<<note1.m[0][1]<<" "<<note1.d[0][0]<<note1.d[0][1]<<" "<<note1.g[0][0]<<note1.g[0][1]<<endl;

}

}

}

cout<<endl;

system("PAUSE");

system("cls");

};

int main()

{

setlocale(LC_ALL,"Russian");

int menu=1;

NOTE note;

for (;menu;)

{

cout<<"Меню\n1. Добавить запись.\n2. Показать дни рождения.\n3. Выход.\nВведите пункт меню: ";

cin>>menu;

cout<<endl;

switch(menu)

{

case 1: {add(note);break;};

case 2: {showd(note);break;};

case 3: {menu=0;break;};

}

}

cout<<endl;

system("pause");

system("cls");

return 0;

}

Результат работы программы:

Завдання №8

Листинг программы:

#include "stdafx.h"

#include <iostream>

#include <Windows.h>

#include <string>

#include <stdlib.h>

#include <math.h>

int main(void)

{

float x,z=0,y=0;

const float hx=0.001,pi=3.13;

HWND hWnd = GetConsoleWindow();

HDC hDC = GetDC(hWnd);

HPEN Pen = CreatePen(PS_SOLID,1,RGB(255,255,255));

HPEN PenT = CreatePen(PS_SOLID,4,RGB(255,255,255));

SelectObject(hDC, Pen);

MoveToEx(hDC, 0, 150, NULL);

LineTo(hDC, 500, 150);

MoveToEx(hDC, 150, 0, NULL);

LineTo(hDC, 150, 300);

SelectObject(hDC, PenT);

x=0;

for (x=-100;x<=100;x+=0.1)

{

z=acos(x)*40;

MoveToEx(hDC,x*20+150,-z+150,NULL);

LineTo(hDC,x*20+150,-z+150);

Sleep(1);

}

system("pause");

ReleaseDC(hWnd, hDC);

return 0;

}

Результат работы программы:

Завдання №9

#include "stdafx.h"

#include <Windows.h>

#include <stdlib.h>

#include <math.h>

int main(void)

{

float const hx=0.1,pi=3.14;

HWND hWnd = GetConsoleWindow();

HDC hDC = GetDC(hWnd);

HPEN PenW = CreatePen(PS_SOLID, 1, RGB(255, 255, 255));

HPEN PenK = CreatePen(PS_SOLID, 1, RGB(73,0,0));

SelectObject(hDC, PenW);

RoundRect(hDC,50,60,90,120,40,100);

Rectangle(hDC,90,10,120,30);

Rectangle(hDC,70,60,210,120);

Rectangle(hDC,140,10,210,20);

MoveToEx(hDC,100,60,NULL);

LineTo(hDC,94,30);

MoveToEx(hDC,110,60,NULL);

LineTo(hDC,116,30);

MoveToEx(hDC,150,10,NULL);

LineTo(hDC,150,60);

MoveToEx(hDC,200,10,NULL);

LineTo(hDC,200,60);

Rectangle(hDC,160,20,170,60);

Rectangle(hDC,180,20,190,60);

SelectObject(hDC,PenK);

MoveToEx(hDC,80,60,NULL);

LineTo(hDC,80,120);

Rectangle(hDC,60,110,100,130);

Rectangle(hDC,140,100,200,130);

RoundRect(hDC,65,120,95,150,100,100);

RoundRect(hDC,70,125,90,145,100,100);

MoveToEx(hDC,70,135,NULL);

LineTo(hDC,90,135);

MoveToEx(hDC,80,125,NULL);

LineTo(hDC,80,145);

RoundRect(hDC,145,120,175,150,100,100);

RoundRect(hDC,150,125,170,145,100,100);

MoveToEx(hDC,150,135,NULL);

LineTo(hDC,170,135);

MoveToEx(hDC,160,125,NULL);

LineTo(hDC,160,145);

RoundRect(hDC,175,120,205,150,100,100);

RoundRect(hDC,180,125,200,145,100,100);

MoveToEx(hDC,180,135,NULL);

LineTo(hDC,200,135);

MoveToEx(hDC,190,125,NULL);

LineTo(hDC,190,145);

SelectObject(hDC,PenW);

Rectangle(hDC,130,40,140,60);

MoveToEx(hDC,127,40,NULL);

LineTo(hDC,143,40);

LineTo(hDC,135,30);

LineTo(hDC,127,40);

ReleaseDC(hWnd, hDC);

system("pause");

return 0;

}

Результат работы программы: