69,369
社区成员
发帖
与我相关
我的任务
分享
// Poker.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
struct Node
{
int no;
int value;
bool hasValue;
};
int _tmain(int argc, _TCHAR* argv[])
{
Node poker[53];
for(int i=1;i<=52;i++)
{
poker[i].no=i;
poker[i].hasValue=false;
}
for(int i=0,value=1,count=0;count<52;)
{
for(int j=0;j<2;j++)
{
do
{
i++;
if(i>52)
i=1;
}while(poker[i].hasValue);
}
poker[i].value=value++;
poker[i].hasValue=true;
count++;
}
for(int i=1;i<=52;i++)
cout<<poker[i].value<<" ";
cout<<endl;
return 0;
}
运行结果:
46 1 27 2 40 3 28 4 51 5 29 6 41 7 30 8 47 9 31 10 42 11 32 12 50 13 33 14 43 15 34 16 48 17 35 18 44 19 36 20 52 21 37 22 45 23 38 24 49 25 39 26