关于排序问题
来源:互联网 发布:wireshark过滤端口抓包 编辑:程序博客网 时间:2024/04/18 12:42
2个小朋友手拉手站成一个圆圈,从第一个小朋友开始报数,报到6的那个小朋友退出到圈外,然后他的下一位重新报“1”。这样继续下去,最后只剩下一个小朋友,他原来站在什么位置上呢? 并把输出小朋友退出圈外的顺序。
#include <stdio.h>
void main()
{
int a[12]={0},b[12]={0};
// a is for children, if a[x]==1 then x is still in the circle.
// b is used to record the get out order.
int count,i,j;
for(i=0;i<12;i++)
{
a[i]=1;
}
i=0;j=0;count=0;
while(j<12)
{
count=count+a[i];
if(count==6)
{
b[j++]=i+1;
count=0;
a[i]=0;
}
i++;
if(12==i)
i=0;
}
printf("The last person in the circle is : %d\n",b[11]);
printf("The order is: ");
for(i=0;i<12;i++)
printf("%d ",b[i]);
printf("\n");
}
0 0
- 关于排序的问题
- 关于gridview排序问题
- 关于CListCtrl排序问题
- 关于map排序问题
- 关于排序问题
- 关于排序的问题
- 关于排序问题
- 关于实现搜索、排序问题
- 关于DBgrid排序的问题
- 关于Map的排序问题
- 关于 Oracle in 排序问题
- Extjs关于GridView排序问题
- 关于NSArray的排序问题
- 关于TreeSet的排序问题
- 关于生产者消费者排序问题
- 关于排序算法耗时问题。
- 关于map的排序问题。
- 关于排序的稳定性问题
- Copy fields from …
- SAP 金额在表中的存储…
- xmemcached
- ABAP Dump when&n…
- function module …
- 关于排序问题
- 从菜鸟成为数据科学家的 9步养成方案
- Android:Material Design on Android Checklist!
- 配置git for eclipse
- 图像处理之应用篇-大米计数续
- hook对应的汇编码0x8B, 0xFF,0x55,0x8B, 0xEC, // mov ebp,esp
- 错误1error LNK2019: 无法解析的外部符号 __imp____glutInitWithExit@12,该符号在函数 _glutInit_ATEXIT_HACK@8 中被引用D:\C+
- 图像处理之添加高斯与泊松噪声
- diamond types are not supported at this language level