卡片游戏
来源:互联网 发布:淘宝卡索卫浴靠谱吗 编辑:程序博客网 时间:2024/04/27 20:14
/*卡片游戏*/
#include<math.h>
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
#define max 100
int a[max];
int main()
{
int i;
int n;
while (cin >> n)
{
int found = 0;//找最后一个数要用到
for (i = 0; i <= n - 1; i++)
{
a[i] = i + 1;
}//按下标赋值
int j = 1;
int number = n ;
int count = 0;//计算除去的个数
for (i = 0;; i++)
{
if (count == n - 1)
{
break;
}
if (a[i]==0) continue;
cout << a[i] << " ";//输出
//cout << "count=" << count;
a[i] = 0;//后排除
if (a[i + 2] != 0)
{
a[number] = a[i + 1];//将下一项移到最后
a[i + 1] = 0;//令下一项不存在
}
count++;
number++;
}
for (i = 0; found != 1; i++)
{
if (a[i] != 0)
{
found = 1;
cout << a[i] << endl;
}
}
}
system("pause");
return 0;
}
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏!!!
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 深搜1 —— Prime Ring Problem
- Linux学习【菜鸟篇】- 学习笔记- Shell(常用命令)
- Android使用本地广播
- OC01_类与对象
- Delphi调用C++ DLL函数,有些类型相关的知识
- 卡片游戏
- iOS之viewController瘦身
- POI导出JavaWeb中的table到excel下载
- windows下批量修改文件(或文件夹)权限或所有者
- 一种通过xmpp实现离线消息推送的方法及系统
- 解决:为保证帐号安全,您在这里的注册受到限制。 建议您下载网易官方手机客户端邮箱大师进行注册 原文信息: 解决:为保证帐号安全,您在这里的注册受到限制。 建议您下载网易官方手机客户端邮箱大师进行注册
- openjudge 雷涛的小猫
- 【Windows编程】笔记-添加音效与窗口创建
- 天声人語 20151205 親心の並ぶランキング