Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
JIHEDlg.cpp
Package: JIHE.rar [view]
Upload User: wl_neon
Upload Date: 2022-08-05
Package Size: 244k
Code Size: 10k
Category:
GUI Develop
Development Platform:
Visual C++
- // JIHEDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "JIHE.h"
- #include "JIHEDlg.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()
- /////////////////////////////////////////////////////////////////////////////
- // CJIHEDlg dialog
- CJIHEDlg::CJIHEDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CJIHEDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CJIHEDlg)
- m_1 = _T("");
- m_2 = _T("");
- m_3 = _T("");
- //}}AFX_DATA_INIT
- // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- }
- void CJIHEDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CJIHEDlg)
- DDX_Text(pDX, IDC_EDIT1, m_1);
- DDX_Text(pDX, IDC_EDIT2, m_2);
- DDX_Text(pDX, IDC_EDIT3, m_3);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CJIHEDlg, CDialog)
- //{{AFX_MSG_MAP(CJIHEDlg)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_BN_CLICKED(IDC_BUTTON1, Onjiao)
- ON_BN_CLICKED(IDC_BUTTON2, Onbing)
- ON_BN_CLICKED(IDC_BUTTON3, Onbu)
- ON_BN_CLICKED(IDC_BUTTON4, Oncha)
- ON_BN_CLICKED(IDC_BUTTON5, Onduichencha)
- ON_BN_CLICKED(IDC_BUTTON6, Onbaohan)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CJIHEDlg message handlers
- BOOL CJIHEDlg::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 CJIHEDlg::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 CJIHEDlg::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 CJIHEDlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }
- int CJIHEDlg::panduanCF()
- {
- UpdateData(1);
- m_3.Empty();
- CString m,n;
- for (int i=0;i<=m_1.GetLength()/2;i++)
- {
- AfxExtractSubString(m, (LPCTSTR)m_1, i, ' ');
- for (int j=i+1;j<=m_1.GetLength()/2;j++)
- {
- AfxExtractSubString(n, (LPCTSTR)m_1, j, ' ');
- if(m==n) {AfxMessageBox("重复输入!");m_1="";m_2="";UpdateData(0);return 1;}
- }
- }
- for ( i=0;i<=m_2.GetLength()/2;i++)
- {
- AfxExtractSubString(m, (LPCTSTR)m_2, i, ' ');
- for (int j=i+1;j<=m_2.GetLength()/2;j++)
- {
- AfxExtractSubString(n, (LPCTSTR)m_2, j, ' ');
- if(m==n) {AfxMessageBox("重复输入!");m_1="";m_2="";UpdateData(0);return 1;}
- }
- }
- return 0;
- }
- void CJIHEDlg::Onjiao()
- {
- UpdateData(1);
- m_3.Empty();
- if(panduanCF()) return;
- CString tem,dem;
- if(m_1=="" && m_2=="") {AfxMessageBox("交集为空,请输入元素"); m_3="";return ;}
- else {if(m_1==""||m_2=="") m_3="空集";
- else
- for (int i=0;i<=m_1.GetLength()/2;i++)
- {
- for (int j=0;j<=m_2.GetLength()/2;j++)
- {
- AfxExtractSubString(tem, (LPCTSTR)m_1, i, ' ');
- AfxExtractSubString(dem, (LPCTSTR)m_2, j, ' ');
- if(tem==dem)
- {
- if(m_3.GetLength()==0)
- m_3=tem;
- else m_3=m_3+" "+tem;
- }
- }
- }
- }
- if(m_3=="") m_3="空集";
- UpdateData(0);
- }
- void CJIHEDlg::Onbing()
- {
- UpdateData(1);
- m_3.Empty();
- UpdateData(0);
- if(m_1=="" && m_2=="") {AfxMessageBox("并集为空,请输入元素"); return ;}
- if(panduanCF()) return;
- if(m_1=="" || m_2=="") {m_3=m_1+m_2;UpdateData(0);return;}
- m_3=m_1;
- CString tem;
- CString dem;
- for (int i=0;i<m_2.GetLength();i++)
- {
- AfxExtractSubString(tem, (LPCTSTR)m_2, i, ' ');
- int flag=0;//没有一样的
- for (int j=0;j<m_1.GetLength();j++)
- {
- AfxExtractSubString(dem, (LPCTSTR)m_1, j, ' ');
- if(tem==dem)
- {flag=1;break;}
- }
- if(flag==0) m_3=m_3+" "+tem;
- }
- UpdateData(0);
- }
- void CJIHEDlg::Onbu()
- {
- UpdateData(1);
- m_3.Empty();
- UpdateData(0);
- if(m_1=="" && m_2=="") {AfxMessageBox("差集为空,请输入元素"); return ;}
- if(panduanCF()) return;
- if(m_2=="") {m_3=m_1;UpdateData(0);return;}
- if(m_1=="") {m_3="空集";UpdateData(0);return;}
- CString tem;
- CString dem;
- for (int i=0;i<=m_1.GetLength();i++)
- {
- int pd=1;
- for (int j=0;j<=m_2.GetLength();j++)
- {
- AfxExtractSubString(tem, (LPCTSTR)m_1, i, ' ');
- AfxExtractSubString(dem, (LPCTSTR)m_2, j, ' ');
- if(tem==dem) {pd=0;break;}
- }
- if (pd==1) m_3=m_3+tem+" ";
- }
- UpdateData(0);
- }
- void CJIHEDlg::Oncha()
- {
- UpdateData(1);
- m_3.Empty();
- UpdateData(0);
- if(m_1=="" && m_2=="") {AfxMessageBox("差集为空,请输入元素"); return ;}
- if(panduanCF()) return;
- if(m_1=="") {m_3=m_2;UpdateData(0);return;}
- if(m_2=="") {m_3="空集";UpdateData(0);return;}
- CString tem;
- CString dem;
- for (int i=0;i<=m_2.GetLength();i++)
- {
- int pd=1;
- for (int j=0;j<=m_1.GetLength();j++)
- {
- AfxExtractSubString(tem, (LPCTSTR)m_2, i, ' ');
- AfxExtractSubString(dem, (LPCTSTR)m_1, j, ' ');
- if(tem==dem) {pd=0;break;}
- }
- if (pd==1) m_3=m_3+tem+" ";
- }
- UpdateData(0);
- }
- void CJIHEDlg::Onduichencha()
- {
- UpdateData(1);
- m_3.Empty();
- UpdateData(0);
- if(m_1=="" && m_2=="") {AfxMessageBox("对称差为空,请输入元素"); return;}
- if(panduanCF()) return;
- if(m_1=="") {m_3=m_2;UpdateData(0);return;}
- if(m_2=="") {m_3=m_1;UpdateData(0);return;}
- CString tem;
- CString dem;
- for (int i=0;i<=m_1.GetLength();i++)
- {
- int pd=1;
- for (int j=0;j<=m_2.GetLength();j++)
- {
- AfxExtractSubString(tem, (LPCTSTR)m_1, i, ' ');
- AfxExtractSubString(dem, (LPCTSTR)m_2, j, ' ');
- if(tem==dem) {pd=0;break;}
- }
- if (pd==1) m_3=m_3+tem+" ";
- }
- for (i=0;i<=m_2.GetLength();i++)
- {
- int pd=1;
- for (int j=0;j<=m_1.GetLength();j++)
- {
- AfxExtractSubString(tem, (LPCTSTR)m_2, i, ' ');
- AfxExtractSubString(dem, (LPCTSTR)m_1, j, ' ');
- if(tem==dem) {pd=0;break;}
- }
- if (pd==1) m_3=m_3+tem+" ";
- }
- UpdateData(0);
- }
- void CJIHEDlg::Onbaohan()
- {
- UpdateData(1);
- m_3.Empty();
- if(m_1==""&&m_2=="") {AfxMessageBox("A B为空集");return;}
- if(panduanCF()) return;
- if(m_1=="") {AfxMessageBox("A为空集,B包含A");return;}
- if(m_2=="") {AfxMessageBox("B为空集,A包含B");return;}
- if(m_1==m_2) {AfxMessageBox("A B相等");return;}
- //////////////////////////////
- CString m_4,tem,dem;//交
- for (int i=0;i<=m_1.GetLength()/2;i++)
- {
- AfxExtractSubString(tem, (LPCTSTR)m_1, i, ' ');
- for (int j=0;j<=m_2.GetLength()/2;j++)
- {
- AfxExtractSubString(dem, (LPCTSTR)m_2, j, ' ');
- if(tem==dem)
- {
- if(m_4=="") m_4=tem;
- else {m_4=m_4+" "+tem;
- break;}
- }
- }
- }
- if(m_4.GetLength()==0) {AfxMessageBox("A B互斥");return;}
- if(m_4.GetLength()/2==m_1.GetLength()/2) {AfxMessageBox("B包含A");return;}
- if(m_4.GetLength()/2==m_2.GetLength()/2) {AfxMessageBox("A包含B"); return;}
- else {AfxMessageBox("A B相交");return;}
- }