• 大小: 47.51MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-08-04
  • 语言: C/C++
  • 标签: mfc  

资源简介

利用MFC可视化图形界面,简单实现了一下约瑟夫环的问题,程序基于vs2013对话框程序。

资源截图

代码片段和文件信息

#include “stdafx.h“
#include “Game.h“
#include “JosephCircleDlg.h“
#include “resource.h“
#include “iostream“
using namespace std;


Game::Game()
{
playernum = 0;
distance = 0;
startposition = 0;
}


Game::~Game()
{
}
struct clink
{
int num;
struct clink *next;
};
struct clink *head;

//Game::Game(CJosephCircleDlg* _dlg int a int b int c)
//{
// dlg = _dlg;
// playernum = a;
// distance = b;
// startposition = c;
//}

int Game::Gamea(CJosephCircleDlg* _dlg int a int b int c)
{
dlg = _dlg;
playernum = a;
distance = b;
startposition = c;
return 0;
}

void Game::Init()
{
struct clink *p;

head = (struct clink *)malloc(sizeof(struct clink));  //创建循环链表
head->next = head;                                    //循环链表为空

for (int i = playernum; i >= 1; i--)
{
p = (struct clink *)malloc(sizeof(struct clink));
p->num = i;
p->next = head->next;
head->next = p;
}
}

void Game::Joseph()
{
struct clink *cir = head;
CString strs;
CEdit *p;

while (cir->next != cir)
{
for (int i = startposition; i < distance+startposition; i++)
{
cir = cir->next;
if (cir == head)
{
cir = cir->next;
}
}
if (cir->next == head)
cir = cir->next;

p = (CEdit *)dlg->GetDlgItem(IDC_OUT);
p->GetWindowText(s);
str.Format(_T(“%d“) cir->next->num);
s = s + “ “ + str;
p->SetWindowText(s);
//AfxMessageBox(s);

struct clink *temp;
temp = cir->next;
cir->next = cir->next->next;
free(temp);


}
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     221696  2017-11-28 08:41  JosephCircle\Debug\JosephCircle.exe

     文件    1391740  2017-11-28 08:41  JosephCircle\Debug\JosephCircle.ilk

     文件    7729152  2017-11-28 08:41  JosephCircle\Debug\JosephCircle.pdb

     文件   94240768  2017-11-28 08:42  JosephCircle\ipch\josephcircle-2a1495b6\josephcircle-6498807.ipch

     文件     175662  2017-11-28 08:39  JosephCircle\JosephCircle\Debug\Game.obj

     文件       1791  2017-11-28 08:41  JosephCircle\JosephCircle\Debug\JosephCircle.log

     文件      42214  2017-11-27 20:11  JosephCircle\JosephCircle\Debug\JosephCircle.obj

     文件   43253760  2017-11-27 15:20  JosephCircle\JosephCircle\Debug\JosephCircle.pch

     文件      69908  2017-11-28 08:41  JosephCircle\JosephCircle\Debug\JosephCircle.res

     文件       2870  2017-11-28 08:39  JosephCircle\JosephCircle\Debug\JosephCircle.tlog\cl.command.1.tlog

     文件      86460  2017-11-28 08:39  JosephCircle\JosephCircle\Debug\JosephCircle.tlog\CL.read.1.tlog

     文件       3482  2017-11-28 08:39  JosephCircle\JosephCircle\Debug\JosephCircle.tlog\CL.write.1.tlog

     文件        162  2017-11-28 08:41  JosephCircle\JosephCircle\Debug\JosephCircle.tlog\JosephCircle.lastbuildstate

     文件       2512  2017-11-28 08:41  JosephCircle\JosephCircle\Debug\JosephCircle.tlog\link.command.1.tlog

     文件       7884  2017-11-28 08:41  JosephCircle\JosephCircle\Debug\JosephCircle.tlog\link.read.1.tlog

     文件        824  2017-11-28 08:41  JosephCircle\JosephCircle\Debug\JosephCircle.tlog\link.write.1.tlog

     文件        640  2017-11-28 08:41  JosephCircle\JosephCircle\Debug\JosephCircle.tlog\rc.command.1.tlog

     文件       2964  2017-11-28 08:41  JosephCircle\JosephCircle\Debug\JosephCircle.tlog\rc.read.1.tlog

     文件        222  2017-11-28 08:41  JosephCircle\JosephCircle\Debug\JosephCircle.tlog\rc.write.1.tlog

     文件      53568  2017-11-27 21:41  JosephCircle\JosephCircle\Debug\JosephCircleDlg.obj

     文件     916603  2017-11-27 15:20  JosephCircle\JosephCircle\Debug\stdafx.obj

     文件    2460672  2017-11-28 08:39  JosephCircle\JosephCircle\Debug\vc120.idb

     文件    6885376  2017-11-28 08:39  JosephCircle\JosephCircle\Debug\vc120.pdb

     文件       1556  2017-11-27 22:33  JosephCircle\JosephCircle\Game.cpp

     文件        364  2017-11-27 19:54  JosephCircle\JosephCircle\Game.h

     文件     109128  2017-11-28 08:41  JosephCircle\JosephCircle\JosephCircle.aps

     文件       2452  2017-11-27 15:20  JosephCircle\JosephCircle\JosephCircle.cpp

     文件        477  2017-11-27 19:30  JosephCircle\JosephCircle\JosephCircle.h

     文件      11480  2017-11-28 08:41  JosephCircle\JosephCircle\JosephCircle.rc

     文件       6258  2017-11-27 20:35  JosephCircle\JosephCircle\JosephCircle.vcxproj

............此处省略25个文件信息

评论

共有 条评论