49772 (Многоголовочная машина Тьюринга), страница 3
Описание файла
Документ из архива "Многоголовочная машина Тьюринга", который расположен в категории "". Всё это находится в предмете "информатика" из 1 семестр, которые можно найти в файловом архиве . Не смотря на прямую связь этого архива с , его также можно найти и в других разделах. Архив можно найти в разделе "курсовые/домашние работы", в предмете "информатика, программирование" в общих файлах.
Онлайн просмотр документа "49772"
Текст 3 страницы из документа "49772"
Рис. 13. Интерфейс программы. Выбор вида разбора
Рис. 14. Интерфейс программы. Ввод слова
Рис. 15. Интерфейс программы. Осуществление разбора
Текст программы:
#include «stdafx.h»
#include «17_Turing.h»
#include «17_TuringDlg.h»
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg: public CDialog
{
public:
CAboutDlg();
// Dialog Data
// {{AFX_DATA(CAboutDlg)
enum {IDD = IDD_ABOUTBOX};
// }} AFX_DATA
// ClassWizard generated virtual function overrides
// {{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange (CDataExchange* pDX); // DDX/DDV support
// }} AFX_VIRTUAL
// Implementation
protected:
// {{AFX_MSG(CAboutDlg)
// }} AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg:CAboutDlg(): CDialog (CAboutDlg:IDD)
{
// {{AFX_DATA_INIT(CAboutDlg)
// }} AFX_DATA_INIT
}
void CAboutDlg: DoDataExchange (CDataExchange* pDX)
{
CDialog: DoDataExchange(pDX);
// {{AFX_DATA_MAP(CAboutDlg)
// }} AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP (CAboutDlg, CDialog)
// {{AFX_MSG_MAP(CAboutDlg)
// No message handlers
// }} AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMy17_TuringDlg dialog
CMy17_TuringDlg:CMy17_TuringDlg (CWnd* pParent /*=NULL*/)
: CDialog (CMy17_TuringDlg:IDD, pParent)
{
// {{AFX_DATA_INIT (CMy17_TuringDlg)
m_text = _T(«»);
otvet = _T(«»);
q = 0;
// }} AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon (IDR_MAINFRAME);
}
void CMy17_TuringDlg: DoDataExchange (CDataExchange* pDX)
{
CDialog: DoDataExchange(pDX);
// {{AFX_DATA_MAP (CMy17_TuringDlg)
DDX_Control (pDX, IDC_EDIT3, q1);
DDX_Control (pDX, IDC_RADIO1, mor);
DDX_Text (pDX, IDC_EDIT1, m_text);
DDX_Text (pDX, IDC_EDIT2, otvet);
DDX_Text (pDX, IDC_EDIT3, q);
// }} AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP (CMy17_TuringDlg, CDialog)
// {{AFX_MSG_MAP (CMy17_TuringDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED (IDC_BUTTON1, OnButton1)
ON_BN_CLICKED (IDC_RADIO1, OnRadio1)
ON_BN_CLICKED (IDC_RADIO2, OnRadio2)
ON_BN_CLICKED (IDC_RADIO3, OnRadio3)
ON_BN_CLICKED (IDC_BUTTON3, OnFileClose)
//ON_BN_CLICKED (IDC_BUTTON4, OnButton4)
ON_BN_CLICKED (IDC_BUTTON2, OnButton2)
// }} AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMy17_TuringDlg message handlers
BOOL CMy17_TuringDlg: OnInitDialog()
{
CDialog: OnInitDialog();
// Add «About…» menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT (IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu!= NULL)
{
CString strAboutMenu;
strAboutMenu. LoadString (IDS_ABOUTBOX);
if (! strAboutMenu. IsEmpty())
{
pSysMenu->AppendMenu (MF_SEPARATOR);
pSysMenu->AppendMenu (MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 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
}
void CMy17_TuringDlg: OnSysCommand (UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout. DoModal();
}
else
{
CDialog: OnSysCommand (nID, lParam);
}
}
// 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 CMy17_TuringDlg: 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 CMy17_TuringDlg: OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CMy17_TuringDlg: OnButton1 ()
{
// TODO: Add your control notification handler code here
UpdateData(true);
int i = strlen (m_text);
char x1 = m_text [i-1];
char x2 = m_text [i-2];
char x3 = m_text [i-3];
{if ((x1 == «й' && (x2 == 'ы» || x2 == «и' || x2 == 'о» || x2 == 'а'))
|| (x1 == «ю' && (x2 =='у» || x2 == 'ю'))
|| (x1 =='е' && (x2 == «и' || x2 =='о» || x2 == 'е' || x2 == 'ы'))
|| (x3 == «о' && ((x2 == 'г» && x1 == «о') || (x2 == 'м» && x1 == 'у'))
|| (x1 == 'м' && x2 == 'ы') ||
(x3 == «е' && x2 =='г» && x1 == 'о')))
{
otvet = «прилагательное»;
}
else
{
if (((x2 == «т' && (x1 == 'ь» || x1 == «и')) || (x1 == 'я» && x2 == 'с'))
|| (x1 == «ь' && x2 == 'т» && (x3 == «а' || x3 == 'е» ||x3 == 'и'))
|| (x1 == «т' && (x2 == 'е» || x2 == «и' || x2 == 'у» || x2 == «ю' || x2 == 'а» || x2 == 'я'))
|| (x1 == «е' && x2 == 'т» && (x3 == 'е' || x3 == 'и'))
|| (x1 == «ь' && x2 == 'ш» && (x3 == 'е' || x3 == 'и'))
|| (x1 == «м' && (x2 == 'и» || x2 == 'и'))
|| x1 == 'У')
{
otvet = «глагол»;
}
else
{
if ((x1=='а'||x1=='я'||x1=='о'||x1=='е'|| x1 == «з' ||x1=='и'||x1=='ы'||x1=='у» || x1 == «ь'|| x1 == 'с» || x1 == «ф' || x1 == 'ы» || x1 == «т' || x1 == 'р» || x1 == 'к')
|| (x2 == «и' && (x1 == 'я» || x1 == 'м' || x1 == 'е'))
|| (x2 == «ь' && (x1 == 'е» || x1 == 'и'))
|| (x2 == «о' && (x1 == 'й» || x1 == 'е'))
|| (x1 == 'а' && x2 == 'я')
|| (x1 == «ь' && x2 == 'т» && x3 == 'с')
|| (x1 == «я' || x2 == 'с» || x3 == 'й'))
{
otvet = «существительное»;
}
else
{
otvet = «yне удаётся распознать»;
}
}
}
UpdateData(false);
}
}
void CMy17_TuringDlg: OnRadio1 ()
{
// TODO: Add your control notification handler code here
q1. EnableWindow(false);
}
void CMy17_TuringDlg: OnRadio2 ()
{
// TODO: Add your control notification handler code here
q1. EnableWindow(true);
}
void CMy17_TuringDlg: OnRadio3 ()
{
// TODO: Add your control notification handler code here
q1. EnableWindow(true);
}
void CMy17_TuringDlg: OnFileClose()
{
// TODO: Add your control notification handler code here
}
void CMy17_TuringDlg: OnButton4 ()
{
// TODO: Add your control notification handler code here
}
void CMy17_TuringDlg: OnButton2 ()
{
otvet = «»;
m_text = «»;
UpdateData(false);
// TODO: Add your control notification handler code here
}
Список литературы
-
Катленд Н. Вычислимость. Введение в теорию рекурсивных функций: Пер. с англ. М.: Мир, 1983.
-
Холзнер С. Visual C++ 6. Учебный курс. СПб.: Питер, 2007.
-
http://ru.wikipedia.org
-
http://www.intuit.ru
-
http://www.metric.ru
-
http://old.osp.ru