UVa 10935 - Throwing cards away I
来源:互联网 发布:网络推广工资多少一般 编辑:程序博客网 时间:2024/05/21 13:23
题意:票数大于二的时候,取第一张牌抛弃,再取一张放在牌底。
输出抛弃的顺序,再输出剩下的一张。
#include <fstream>#include <iostream>#include <string>#include <complex>#include <math.h>#include <set>#include <vector>#include <map>#include <queue>#include <stdio.h>#include <stack>#include <algorithm>#include <list>#include <ctime>#include <memory.h>#include <ctime>#include <assert.h>#define rep(i,a,n) for (int i=a;i<n;i++)#define per(i,a,n) for (int i=n-1;i>=a;i--)#define pb push_back#define mp make_pair#define all(x) (x).begin(),(x).end()#define fi first#define se second#define eps 1e-8#define M_PI 3.141592653589793typedef long long ll;const ll mod=1000000007;const int inf=99999999;ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}using namespace std;int main(){ int n,a[220]; while(cin>>n&&n){ int head=0,tail=n-1; for(int i=0;i<n;i++) a[i]=i+1; cout<<"Discarded cards:"; while(tail-head>=1){ int x=a[head];head++; cout<<" "<<x; if(tail-head>=1) cout<<","; a[++tail]=a[head++]; } cout<<endl; cout<<"Remaining card: "<<a[head]<<endl; }}
0 0
- UVA 10935 - Throwing cards away I
- UVA 10935 - Throwing cards away I
- UVa 10935 - Throwing cards away I STL
- uva 10935 - Throwing cards away I
- UVa 10935 Throwing cards away I
- UVA - 10935 Throwing cards away I
- Uva 10935 Throwing cards away I
- UVa 10935 - Throwing cards away I
- UVa 10935 - Throwing cards away I
- UVa 10935 - Throwing cards away I
- UVA - 10935 Throwing cards away I (数组)
- UVa 10935 - Throwing cards away I
- Uva - 10935 - Throwing cards away I
- UVa 10935 - Throwing cards away I
- UVa 10935 - Throwing cards away I
- Uva 10935 Throwing cards away I
- UVa 10935 Throwing cards away I
- uva 10935Throwing cards away I
- Android开发:15分钟学会Java正则表达式
- python数据可视化--散点图以及分类
- OpenStack-RPC-server的构建(三)
- Swift 数组
- .net发邮件
- UVa 10935 - Throwing cards away I
- C++学习:类成员的访问范围
- Android 之一个很好的Viewpager滑动指示器
- Activity的四种启动模式和onNewIntent()
- Canvas,Paint简介
- Hadoop源码分析
- ios中两个viewcontroller之间如何传递数据
- openstack之ironic分析
- 如何下载一个视频文件到Documents目录下的Video文件夹