Министерство образования республики Беларусь
Учреждение образования
«БЕЛОРУССКИЙ ГОСУДАРСТВЕННЫЙ УНИВЕРСИТЕТ ИНФОРМАТИКИ И РАДИОЭЛЕКТРОНИКИ»
Институт информационных технологий
Специальность__«Информационные технологии и управление
в технических системах»________________________________
Контрольная работа
По курсу _«Технология разработки программного обеспечения____
____ систем управления»______
Вариант №__11__
Студент-заочник_II_ курса
Группы № 982425_______
ФИО _Краснов Александр
_Евгеньевич____________
Адрес Витебская обл, г. Городок, ул. Комсомольская д.19 кв.38
Тел. 80336617068 (МТС)_____
Минск, 2011
Лабораторная работа №1.
Мастера Сlassview и Сlasswizard в Visual C++ 6.0
11. .
// x.cpp: implementation of the x class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "zadacha_1.h"
#include "x.h"
#include "math.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
x::x()
{
}
x::~x()
{
}
/* обьявление методов */
void x::run() // метод для вычесления значений z1 и z2
{
z1=(sqrt(pow((3*y+2), 2)-24*y))/((3*sqrt(y))-(2/sqrt(y)));
z2=-sqrt(y);
}
void x::print() // метод для вывода результатов
{
CString str;
/* объявили строковый объект класса библиотеки MFC, и при помощи его вызвали метод, который работает как стандартная функция printf(…), но выводит значения объектов из списка вывода в указанную строку*/
str.Format("Для X =%5.2f\nZ1 =%5.2f\nZ2 =%5.2f",y, z1, z2);
AfxMessageBox(str);
}
void x::set(double a) // метод для инициализации класса
{
y=a;
}
// zadacha_1Dlg.cpp : implementation file
#include "stdafx.h"
#include "zadacha_1.h"
#include "zadacha_1Dlg.h"
#include "x.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CZadacha_1Dlg dialog
CZadacha_1Dlg::CZadacha_1Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CZadacha_1Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CZadacha_1Dlg)
m_x = 0.0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CZadacha_1Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CZadacha_1Dlg)
DDX_Text(pDX, IDC_EDIT1, m_m);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CZadacha_1Dlg, CDialog)
//{{AFX_MSG_MAP(CZadacha_1Dlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CZadacha_1Dlg message handlers
BOOL CZadacha_1Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CZadacha_1Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CZadacha_1Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CZadacha_1Dlg::OnButton1()
{
UpdateData(TRUE); // данные считываються из элементов управления диалогового окна
//и обновляються переменные оконного объекта
if ((m_x<=0)||(m_x==2/3)) // проверка исходных данных на отсутствие решения
AfxMessageBox("Значение должно быть больше 0 и не равно 2/3\n Bведите новое значение!");
else {
x x1; // Конструктор класса x создает объект x1
x1.set(m_x); // инициализация данных
x1.run(); // вычисление
x1.print(); // вывод
}
UpdateData(FALSE); // обновляет содержимое элементов управления диалогового окна
}
void CZadacha_1Dlg::OnButton2()
{
OnOK();
}
Лабораторная работа №4.
Работа с элементом управления «Окно списка» (ListBox)
11.
// zadacha_3Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "zadacha_3.h"
#include "zadacha_3Dlg.h"
#include "math.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CZadacha_3Dlg dialog
CZadacha_3Dlg::CZadacha_3Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CZadacha_3Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CZadacha_3Dlg)
m_x1 = 0.0;
m_x2 = 0.0;
m_h = 0.0;
m_n = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CZadacha_3Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CZadacha_3Dlg)
DDX_Control(pDX, IDC_LIST1, m_l);
DDX_Text(pDX, IDC_EDIT1, m_x1);
DDV_MinMaxDouble(pDX, m_x1, 0.1, 0.3);
DDX_Text(pDX, IDC_EDIT2, m_x2);
DDV_MinMaxDouble(pDX, m_x2, 0.7, 0.9);
DDX_Text(pDX, IDC_EDIT3, m_h);
DDV_MinMaxDouble(pDX, m_h, 0.1, 0.2);
DDX_Text(pDX, IDC_EDIT4, m_n);
DDV_MinMaxInt(pDX, m_n, 5, 20);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CZadacha_3Dlg, CDialog)
//{{AFX_MSG_MAP(CZadacha_3Dlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CZadacha_3Dlg message handlers
BOOL CZadacha_3Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CZadacha_3Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CZadacha_3Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
int i,m_n;
double x,m_x1,m_x2,m_h,s,y,fak;
CString str;
void CZadacha_3Dlg::OnButton1()
{
UpdateData(true);
m_l.ResetContent ();// очиска на случай если не была произведена очистка
str.Format("datas: x1=%.2f, x2=%.2f, h=%.2f, n=%d", m_x1, m_x2, m_h, m_n);
m_l.AddString(str);
UpdateData(false);
for (x=m_x1;x<=m_x2;x+=m_h)
{s=1;fak=1;
y=(1+2*pow(x,2))*exp(pow(x,2));
for(i=1;i<=m_n;i++)
{
fak*=i;
s+=(2*i+1)/fak*pow(x,2*i);
}
str.Format("Для x=%.2f, сумма=%.2f, y=%.2f", x,s,y);
m_l.AddString(str);
UpdateData(true);
}
//UpdateData(FALSE);
}
void CZadacha_3Dlg::OnButton2()
{
// TODO: Add your control notification handler code here
m_l.ResetContent ();
}