資源簡介
密度聚類c++寫的,有mfc可視化界面。k均值還沒寫后面寫了再上傳。初學者沒積分下別人的文檔硬剛了半個多月寫的,期間踩坑無數,同樣沒積分的兄弟留言給你百度云分享。有興趣又有積分的朋友希望能給我貢獻兩個下載積分------------

代碼片段和文件信息
//?CDialogGuss.cpp:?實現文件
//
#include?“stdafx.h“
#include?“mfc_plot.h“
#include?“CDialogGuss.h“
#include?“afxdialogex.h“
//?CDialogGuss?對話框
IMPLEMENT_DYNAMIC(CDialogGuss?CDialogEx)
CDialogGuss::CDialogGuss(CWnd*?pParent?/*=nullptr*/)
:?CDialogEx(IDD_DIALOGGUSS?pParent)?
Guss_equ(0.0)Guss_var(10.0)Guss_num(500)
{
}
CDialogGuss::~CDialogGuss()
{
}
void?CDialogGuss::DoDataExchange(CDataExchange*?pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX?IDC_EDITE?m_equ);
DDX_Control(pDX?IDC_EDITV?m_var);
DDX_Control(pDX?IDC_EDITN?m_num);
m_equ.SetWindowTextW(_T(“0.0“));
m_var.SetWindowTextW(_T(“20.0“));
m_num.SetWindowTextW(_T(“100“));
}
BEGIN_MESSAGE_MAP(CDialogGuss?CDialogEx)
ON_BN_CLICKED(IDOK?&CDialogGuss::OnBnClickedOk)
END_MESSAGE_MAP()
//?CDialogGuss?消息處理程序
void?CDialogGuss::OnBnClickedOk()
{
//?TODO:?在此添加控件通知處理程序代碼
CString?str1=_T(““)?str2?=?_T(““)?str3?=?_T(““);
m_equ.GetWindowTextW(str1);
m_var.GetWindowTextW(str2);
m_num.GetWindowTextW(str3);
if?(str1==str1.SpanIncluding(_T(“0123456789.-“))?&&?str2?==?str2.SpanIncluding(_T(“0123456789.-“))?&&?str3?==?str3.SpanIncluding(_T(“0123456789“)))
{
Guss_equ?=?_ttof(str1);
Guss_var?=?_ttof(str2);
Guss_num?=?_ttof(str3);
if?(Guss_num?==?0)
{
MessageBox(_T(“樣本數不能小于0!“));
return;
}
CDialogEx::OnOK();
MessageBox(_T(“請左鍵單擊空白處生成樣本點“));
return;
}
else?{
MessageBox(_T(“請輸入正確的參數!均值方差可以為負數小數而數量必須是正整數!“));
return;
}
}
vector>?CDialogGuss::GussDataVec(const?float?equ?const?float?var?const?int?num)?{
static?double?V1?V2?S;
static?int?phaseX?=?0?phaseY?=1;
double?XY;
vector>?my_points;
pair?one_point;
for?(int?i?=?0;?i?!=?num;?++i)?{
if?(phaseX?==?0)?{
do?{
double?U1?=?(double)rand()?/?RAND_MAX;
double?U2?=?(double)rand()?/?RAND_MAX;
V1?=?2?*?U1?-?1;
V2?=?2?*?U2?-?1;
S?=?V1?*?V1?+?V2?*?V2;
}?while?(S?>=?1?||?S?==?0);
X?=?V1?*?sqrt(-2?*?log(S)?/?S);
}
else
X?=?V2?*?sqrt(-2?*?log(S)?/?S);
phaseX?=?1?-?phaseX;
X?=?X?*?var?+?equ;
if?(phaseY?==?0)?{
do?{
double?U1?=?(double)rand()?/?RAND_MAX;
double?U2?=?(double)rand()?/?RAND_MAX;
V1?=?2?*?U1?-?1;
V2?=?2?*?U2?-?1;
S?=?V1?*?V1?+?V2?*?V2;
}?while?(S?>=?1?||?S?==?0);
Y?=?V1?*?sqrt(-2?*?log(S)?/?S);
}
else
Y?=?V2?*?sqrt(-2?*?log(S)?/?S);
phaseY?=?1?-?phaseY;
Y?=?Y?*?var?+?equ;
one_point=make_pair(X?Y);
my_points.push_back(one_point);
}
return?my_points;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2777??2018-11-25?22:33??mfc_plot\mfc_plot\CDialogGuss.cpp
?????文件????????803??2018-11-19?00:10??mfc_plot\mfc_plot\CDialogGuss.h
?????文件???????1156??2018-11-25?20:55??mfc_plot\mfc_plot\CParameterDlg.cpp
?????文件????????644??2018-11-25?17:16??mfc_plot\mfc_plot\CParameterDlg.h
?????文件???????5315??2018-11-25?22:13??mfc_plot\mfc_plot\dbsacn.h
?????文件???????3296??2018-11-20?21:35??mfc_plot\mfc_plot\DBSCAN.h
?????文件???????8725??2018-11-18?22:46??mfc_plot\mfc_plot\MainFrm.cpp
?????文件???????1295??2018-11-17?15:40??mfc_plot\mfc_plot\MainFrm.h
?????文件??????29624??2018-11-25?17:16??mfc_plot\mfc_plot\mfcplot.rc
?????文件???????4858??2018-11-17?15:40??mfc_plot\mfc_plot\mfc_plot.cpp
?????文件????????715??2018-11-17?15:40??mfc_plot\mfc_plot\mfc_plot.h
?????文件??????10935??2018-11-25?17:16??mfc_plot\mfc_plot\mfc_plot.vcxproj
?????文件???????3293??2018-11-25?17:16??mfc_plot\mfc_plot\mfc_plot.vcxproj.filters
?????文件????????230??2018-11-18?20:01??mfc_plot\mfc_plot\mfc_plot.vcxproj.user
?????文件???????2732??2018-11-18?22:41??mfc_plot\mfc_plot\mfc_plotDoc.cpp
?????文件????????911??2018-11-18?21:28??mfc_plot\mfc_plot\mfc_plotDoc.h
?????文件???????6642??2018-11-25?22:21??mfc_plot\mfc_plot\mfc_plotView.cpp
?????文件???????1438??2018-11-25?14:41??mfc_plot\mfc_plot\mfc_plotView.h
?????文件???????1654??2018-11-15?22:17??mfc_plot\mfc_plot\res\info.bmp
?????文件????????670??2018-11-17?15:40??mfc_plot\mfc_plot\res\mfcplot.rc2
?????文件??????67777??2018-11-15?22:17??mfc_plot\mfc_plot\res\mfc_plot.ico
?????文件???????4710??2018-11-15?22:17??mfc_plot\mfc_plot\res\mfc_plotDoc.ico
?????文件???????1078??2018-11-15?22:17??mfc_plot\mfc_plot\res\Toolbar.bmp
?????文件???????5816??2018-11-15?22:17??mfc_plot\mfc_plot\res\Toolbar256.bmp
?????文件???????7976??2018-11-15?22:17??mfc_plot\mfc_plot\res\userimages.bmp
?????文件???????2682??2018-11-25?16:54??mfc_plot\mfc_plot\resource.h
?????文件????????177??2018-11-17?15:40??mfc_plot\mfc_plot\stdafx.cpp
?????文件???????1085??2018-11-25?17:16??mfc_plot\mfc_plot\stdafx.h
?????文件????????299??2018-11-17?15:40??mfc_plot\mfc_plot\targetver.h
?????文件???????1436??2018-11-25?22:16??mfc_plot\mfc_plot.sln
............此處省略9個文件信息
- 上一篇:學生成績管理系統v1.0
- 下一篇:黑白棋游戲c語言代碼
評論
共有 條評論