C++数组。
来源:互联网 发布:云计算相关股票有哪些 编辑:程序博客网 时间:2024/06/09 19:47
#include <iostream>using namespace std;//指定一个位置开始,然后每隔k个位置剔除一个元素,输出最后剩余的元素。//相当于所有数据绕成一圈,按k个位置长度剔除数据,当只剩一个时,游戏结束,得到结果.int Grial(int a[],int end,int start,int k){int n = end;int i = start;while(n>1){int m = (i+=k)%n;for(;m<n-1;m++){a[m]=a[m+1];}n--;}return a[n];}int main(){int a[]={1,2,3,4,5,6,7,8,9};cout<<Grial(a,9,2,3)<<endl;return 0;}
0 0
- C 数组
- C 数组
- [C#]数组
- C 数组
- C-数组
- C-------数组
- c++-------------数组
- 【C#】数组
- C数组
- 【C++】 数组
- 【C++】数组
- C:数组
- C数组
- c数组
- C数组
- [C++]数组
- C数组
- 【C#】数组
- rails acts_as_nested_set
- DB2数据库使用过程整理
- 终端命令目录
- javascript字符串的使用
- rails 为表添加1列
- C++数组。
- .nil? , .empty?, .blank? .present? 的区别
- when you start Windows 7: "The Windows Boot Configuration Data file is missing required information"
- unity3D技术之WaitForEndOfFrame 等待帧结束
- 剑指offer 面试题32—从1到n整数中1出现的次数
- 史上一流的好书都在这里!
- pwd
- Android开发优化系列之使用软引用和弱引用
- linux expect 实例