斗地主发牌系统

// ConsoleApplication2.cpp: 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include 

#include 
#include 

#define	DA 0
#define	XIAO 1
#define		HEI 2
#define		HONG 3
#define		MEI 4
#define		FANG 5

struct PAI {
	int zhi;
	int se;
};

const char* se[] = { "大","小","黑桃","红桃","梅花","方块" };
const char* zhi[] = { "3","4","5","6","7","8","9","10","j","q","k","1","2","王" };
void shuchu(PAI pai) {
	/*if(pai.se==WANG){
	std::cout<<(pai.zhi==1?"大":"小")<20) {
			do {
				zhi2 = rand() % 14;
			} while (zhi2 == pk.zhi);
		}
		if (len>41) {
			do {
				zhi3 = rand() % 14;
			} while (zhi3 == pk.zhi || zhi3 == zhi2);
		}

		p[plen++] = pk;
		for (int i = k; i20) {
			zhi2 = rand() % 14;
		}
		if (len>41) {
			do {
				zhi3 = rand() % 14;
			} while (zhi3 == zhi2);
		}

		//随机其他的牌
		while (len != maxlen - shu) {
			do {
				k = rand() % len;
			} while (zhi3 == k || k == zhi2);
			PAI pk = pai[k];
			p[plen++] = pk;
			for (int i = k; i= 0; --i) {
			if (jishu>0) {
				if (jishu == 5)
					return true;
				if (zhi == pai[i].zhi) {
					jishu--;
				}
				else if (zhi + 1 != pai[i].zhi)
				{
					zhi = -1;
					memset(s, 0, 4 * jishu);
					jishu = 0;
				}
			}
			if (pai[i].zhi<12) {
				zhi = pai[i].zhi;
				s[jishu++] = i;
			}
		}
		return false;
	}
};

bool pd(PAI& a, PAI& b) {
	return (a.zhi == b.zhi ? a.seb.zhi);
}

void main() {
	{
		Doudizhu d;
		//d.show();
		int a = 13;
		PAI pai[13];
		d.fapai(a, pai);
		std::cout << "---------------------\n";
		d.Sort(pai, a, pd);
		for (int i = 0; i

 

你可能感兴趣的:(C++)