二年级米分米厘米换算:(约瑟夫问题)的流程图

来源:百度文库 编辑:高校问答 时间:2020/10/28 19:58:27
哪位大虾能帮我搞定这个程序(约瑟夫问题)的流程图啊,小弟感激不尽啊
#define Y 37
#define X 5
main()
{
int people[Y]={0}; /*将 这个数组的元素全部赋值为0*/
int count=1;
int i=0,position=-1;
int dead;
clrscr();
while(count<=Y)
{
do
{
position =(position+1)%Y; /*将约瑟夫问题环状处理*/
if(people[position]==0)
i++;
if(i==X) /*如果 I=5 跳出循环*/
{
i=0;
break;
}
} while(1);
people[position]=count; /*当计数器count=37时,输出结果*/
count++;
}
printf("\n the array of Josephus is :"); /*输出约瑟夫排列*/
for(i=0;i<Y;i++)
printf("%d ",people[i]);
printf("\n\nhow many people do you kill:");
scanf("%d",&dead);
printf("\n the position of this people is :\n", dead);
for(i=0;i<Y;i++)
{
if(people[i]>dead)
printf("$"); /* $为活着的人*/
else
printf("@");
if((i+1)%5==0)
printf(" ");
}
printf("\n");
}

[em10][em10][em10][em10][em10][em10][em10][em10][em10]