惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

博客园 - 无痕的泪

任务栏不显示任务、不能有文件拖动、粘贴操作 登陆qq.电脑重启 WEB测试之兼容性测试 如何编写测试计划 boot disk failure,insert system disk and press enter quick sort 快速排序法 网游名字-调查 赖子山庄工作记录 软件测试面试题目————征求更好答案 比google 百度 更强(http://www.new1000.cn ) google sitemap 介绍(转载) server 2003 directx被禁用 Sql server 2005 的安装 loadrunner的安装 LoadRunner8.1 安装汉化 出错 软件测试准备(摘要) 网站测试方法 软件测试(分类,方法,工具) 软件测试分类
使用数组的方法,解决Josephus问题 - 无痕的泪 - 博客园
无痕的泪 · 2008-10-31 · via 博客园 - 无痕的泪

void main()             //使用数组的方法,解决Josephus问题-----还没搞懂
{
 const int num=20;
 int interval;
 int a[num];
 for(int x=0;x<num;x++)
  a[x]=x+1;
 cout<<"please input the interval:";
 cin>>interval;
 for(int j=0;j<num;j++)
  cout<<a[j]<<",";
 cout<<endl;

 int k=1;
 int i=-1;

 while(1)
 {
  for(int j=0;j<interval;)
  {
   i=(i+1)%num;
   if(a[i]!=0)
    j++;
  }
  if(k==num)break;
  cout<<a[i]<<",";
  a[i]=0;

  k++;
 }
 cout<<"\n no."<<a[i]<<" boy's won.\n";
}