登录
首页 » C# » Description : Let numbered 1, 2, ..., n (NGT; 0) clockwise direction by individu...

Description : Let numbered 1, 2, ..., n (NGT; 0) clockwise direction by individu...

于 2023-04-25 发布 文件大小:20.54 kB
0 41
下载积分: 2 下载次数: 1

代码说明:

描述:设编号为1,2,…,n(n>0)个人按顺时针方向围坐一圈,每人持有一个正整数密码。开始时任意给出一个报数上限值m,从第一个人开始顺时针方向自1起顺序报数,报到m时停止报数,抱m的人出列,从他在顺时针方向上的下一个人起重新自1起顺序报数;如此下去,直到所有人全部出列为止。要求设计一个程序模拟此过程,并给出出列人的编号序列。 .算法思想: Jeseph函数是实现问题要求的主要函数,其算法思想是:从1至m对带头结点的单循环链表循环计数,到m时,输出该结点的编号值,,再从该结点的下一个结点起重新自1起循环计数;如此下去,直到单循环链表空时循环过程结束。 -Description : Let numbered 1, 2, ..., n (NGT; 0) clockwise direction by individuals sitting around a circle, each holding a positive integer code. At the beginning of a given arbitrary reported few limits on m, started from the first clockwise direction from the starting sequence reported a few, when they report back m reported few, hold out the m out from the clockwise direction in the next personal re-order starting from a newspaper; This situation continues until all people so far shown up. Asked to design a simulation of this process, and give out the number of people out sequence. . Algorithm thinking : Jeseph function is to seek to achieve the main function of the algorithm is thinking : m f

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • c++ 邮件群发 例子源码
       #include "stdafx.h" #include #include #include "Resource.h" #include "TabDlg1.h" #include "winsock2.h"#include "stdafx.h"#include #include #include "Resource.h"#include "MainDlg.h" #include "TabDlg1.h" #include "TabDlg2.h" #include "TabDlg3.h" #include "winsock2.h"#define WM_CLICKBIT (WM_USER 1) //最小化,消息定义NOTIFYICONDATA nid;RECT RectForm; //广告窗口坐标 HFONT hFontURLNotVisit;//字体HFONT hFontURLVisited;extern TCHAR tcRunPath[MAX_PATH]; //程序当前路径目录HINSTANCE hInst; static HWND Child1hWnd,Child2hWnd,Child3hWnd; //TAB Control 3个子窗口句柄int initDialog(HWND hwnd)//初始化TAB CTR控件{ //TCHAR szWebSite[100]="http://returnc.com/archives/300.html"; //ShellExecute(hwnd,TEXT("open"),szWebSite,TEXT(""),NULL,SW_SHOWMAXIMIZED); HWND hwndTab = GetDlgItem(hwnd, IDC_TAB1); InitCommonControls(); TCITEM ItemStruct;//定义TAB的参数的结构体 ItemStruct.mask = TCIF_TEXT;//标签 ItemStruct.iImage = 0;//图像 ItemStruct.lParam = 0; ItemStruct.pszText = "SMTP设置";//选项的字符 ItemStruct.cchTextMax = 10; SendMessage(hwndTab, TCM_INSERTITEM, 0, (LPARAM)&ItemStruct);//不用SendMessage用 //TabCtrl_InsertItem(hwndTab,0,&ItemStruct);是一样一样的。 ItemStruct.pszText = "邮件内容";//同上,就是重新定义一下选项的字符 SendMessage(hwndTab, TCM_INSERTITEM, 1, (LPARAM)&ItemStruct); ItemStruct.pszText = "收件箱"; SendMessage(hwndTab, TCM_INSERTITEM, 2, (LPARAM)&ItemStruct); //Child1hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DIALOG1), hwndTab, (DLGPROC)NULL, 0); //网上出现的是上面这个版本,我一开始用这个,给折腾到死都没得到子窗口控件,得不到控件就没法设置了 //因为后面的(DLGPROC)被置空了。这里置空,TAB只能当摆设,所以改成你自己建好的TAB1.CPP中的PROC函数就好了 Child1hWnd = CreateDialogParam((HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE),MAKEINTRESOURCE(IDD_DIALOG1),hwndTab,(DLGPROC)TAB1_Proc,0);//创建子窗口 Child2hWnd = CreateDialogParam((HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE),MAKEINTRESOURCE(IDD_DIALOG2),hwndTab,(DLGPROC)TAB2_Proc,0); Child3hWnd = CreateDialogParam((HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE),MAKEINTRESOURCE(IDD_DIALOG3),hwndTab,(DLGPROC)TAB3_Proc,0); ShowWindow(Child1hWnd, SW_SHOWDEFAULT); //默认显示一下第一个窗口 return 0; } BOOL WINAPI Main_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ HWND hwndTab = GetDlgItem(hWnd, IDC_TAB1);//TAB Control句柄 HWND hwnd_Link=GetDlgItem(hWnd,IDC_SYSLINK1);//Syslink Control 文字链接——版权句柄 switch(uMsg) { HANDLE_MSG(hWnd, WM_INITDIALOG, Main_OnInitDialog); HANDLE_MSG(hWnd, WM_COMMAND, Main_OnCommand); HANDLE_MSG(hWnd,WM_CLOSE, Main_OnClose); HANDLE_MSG(hWnd, WM_SYSCOMMAND, Main_OnSysCommand); //最小化到托盘 HANDLE_MSG(hWnd,WM_LBUTTONDOWN,Main_OnLButtonDown);//左键点击 HANDLE_MSG(hWnd,WM_MOUSEMOVE, Main_OnMouseMove); //鼠标移动范围 HANDLE_MSG(hWnd,WM_PAINT, Main_OnPaint); //点击后显示网站 //HANDLE_MSG(hwnd,WM_CTLCOLORSTATIC, Main_OnCtlColor); case WM_CLICKBIT://最小化后,点击图标 { if(wParam == IDI_ICON1) { switch(lParam) { case WM_LBUTTONDBLCLK://左键双击事件 { ShowWindow(hWnd, SW_SHOWNORMAL); //显示窗口 Shell_NotifyIcon(NIM_DELETE, &nid);//删除托盘图标 SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);//设置窗口坐标 } break; case WM_RBUTTONUP://右键起来时弹出快捷菜单,待完善” { MessageBox(hWnd,TEXT("作者比较懒,右键功能还没添加,双击左键恢复主窗口"),TEXT("憨笑"),MB_OK); } break; default: // ShowWindow(hWnd, SW_HIDE); break; } return TRUE; } else { return FALSE; } } break; case WM_NOTIFY: { /* switch (((LPNMHDR)lParam)->code)//文字链接部分 //TAB CONTROL 控件选择操作&文字链接 **********这一段经百次测试,10分之一左右的概率出现内存读取错误,疑似(LPNMHDR)lParam)->code读取问题 { case NM_CLICK ://点击 //case NM_RETURN ://回车键都可以打开链接 { PNMLINK pNMLink = (PNMLINK)lParam; LITEM item = pNMLink->item; NMHDR hdr = pNMLink->hdr; if ((hdr.hwndFrom == hwnd_Link) && (item.iLink == 0)) { ShellExecute(hWnd,TEXT("open"),"http://www.bachengxie.com/?p=300",TEXT(""),NULL,SW_SHOWMAXIMIZED);//打开网站 return TRUE; } else { return FALSE; } } break; default: break; } */ if ( *(LPDWORD)((LPBYTE)lParam 8)==TCN_SELCHANGE ) //子窗口选择 { int i = TabCtrl_GetCurSel(hwndTab);//返回TAB CTR选择页编号,显示对应窗口数据 switch (i) { case 0: { ShowWindow(Child1hWnd,SW_SHOWDEFAULT); ShowWindow(Child2hWnd,SW_HIDE); ShowWindow(Child3hWnd,SW_HIDE); } break; case 1: { ShowWindow(Child2hWnd,SW_SHOWDEFAULT); ShowWindow(Child1hWnd,SW_HIDE); ShowWindow(Child3hWnd,SW_HIDE); } break; case 2: { ShowWindow(Child3hWnd,SW_SHOWDEFAULT); ShowWindow(Child1hWnd,SW_HIDE); ShowWindow(Child2hWnd,SW_HIDE); } break; default: break; } return TRUE; } else { return FALSE; } } break; default: break; } return FALSE; }BOOL Main_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam){ SkinH_AttachEx(("skins/china.she"), NULL); //载入皮肤 initDialog(hwnd); //初始化TAB控件 hFontURLNotVisit=CreateFont(15,6,0,0,0,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FF_DONTCARE,"黑体");//设置TAB控件字体大小 //SendDlgItemMessage(hwnd,IDC_TAB1,WM_SETFONT,(WPARAM)hFontURLNotVisit,0); //设置TAB字体 return TRUE;}void Main_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify){ switch(id) { case IDC_TOTRAY: { ToTray(hwnd); //最小化到系统托盘 } break; case ID_HELP: { ShellExecute(NULL,"open","ReadMe.txt",NULL,NULL,SW_SHOWNORMAL); //打开ReadMe文本。 } break; default: break; }}void Main_OnClose(HWND hwnd){ SkinH_Detach(); //释放窗口皮肤 EndDialog(hwnd, 0);}void Main_OnPaint(HWND hwnd) //设置起始点及图片大小{ GetClientRect(hwnd,&RectForm); MoveWindow(GetDlgItem(hwnd,IDC_STATIC_AD),RectForm.left 20,RectForm.top 20,523,80,TRUE); //X,Y分别为30和20的顶点坐标,长为430,宽为90,自我理解} void Main_OnLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags){ GetClientRect(hwnd,&RectForm); if(x>=RectForm.left 20 && x=RectForm.top 20 && y=RectForm.left 20 && x=RectForm.top 20 && y
    2014-12-15下载
    积分:1
  • Background-Subtraction-using-GMM
    说明:  基于混合高斯滤波的背景建模,可根据一段视频生成清晰的背景图像(Background Modeling Based on Mixture Gauss Filtering can generate a clear background image from a video.)
    2019-07-08 16:52:59下载
    积分:1
  • MPLAB_IDE
    MPLAB_IDE中文资料 中文介绍 MPLAB_IDE(MPLAB_IDE Chinese Information Chinese Introduction MPLAB_IDE)
    2013-08-07 22:13:04下载
    积分:1
  • ads1256芯片资料
    说明:  ADS1256多通道采集模块,电路图电路图电路图(Multi-channel acquisition module, circuit diagram circuit diagram circuit diagram)
    2020-06-18 02:00:02下载
    积分:1
  • Cmatlabsimulaa
    用matlab进行二级倒立摆摆仿真,进行极点配置 (Two inverted Swing simulation using matlab and pole placement)
    2012-08-05 09:31:28下载
    积分:1
  • ewr
    werwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwewerwerwe
    2022-02-02 16:20:37下载
    积分:1
  • STM32F107VC_ETH_DP83848_lwip2
    说明:  lwip上实现netbios,STM32F107VC平台(lwip netbios STM32F107VC mcu)
    2020-06-20 06:00:01下载
    积分:1
  • 多边形网格
    这是一个与三角的多边形网格的程序:D
    2022-08-19 10:16:56下载
    积分:1
  • C #摄像头编程,你可以捕捉摄像头流
    c# 的摄像头编程,可以采集摄像头的流-c# camera programming, you can capture streaming camera
    2022-10-02 10:10:04下载
    积分:1
  • GH0STwin7
    gh0st的源码可以支持win7下使用 (gh0st source supports use under win7)
    2016-09-18 17:56:51下载
    积分:1
  • 696518资源总数
  • 104331会员总数
  • 24今日下载