摘要: //queen.hclass Queen{private: int number;//皇后数 bool *row;//行是否有随机数 bool *diag;//主对角线是否有皇后数 bool *backDiag;//反对角线是否有皇后数 int *x;//解 static int num;//解得个数 //辅助函数 void BackTracking(int c);//回溯法递归求解 void Show();//显示解public: Queen(); virtual ~Queen(); void Run();};int Queen::num=0;Queen::Queen(){ cout< 阅读全文
posted @ 2012-11-22 23:12 ♂咱說 ろ算 阅读(197) 评论(0) 推荐(0) 编辑
摘要: /*任务:一群小孩围成一圈,任意假定一个数m,从第一个小孩起,顺时针方向数,每数到第m个小孩时,该小孩便离开。小孩不断离开,圈子不断缩小。最后剩下的一个小孩便是胜者。求胜者的编号?要求以面向对象技术进行程序设计建立环状链表类程序便于维护与扩张:如易于对小孩数量n和数数间隔m进行变化改变获胜者数量,使其可设为任意值可中途增加小孩人数*///类的实现#include<iostream>using namespace std;typedef int ElemType;typedef struct List{ ElemType data; struct List *next;}LinkNo 阅读全文
posted @ 2012-11-22 23:09 ♂咱說 ろ算 阅读(272) 评论(0) 推荐(0) 编辑
摘要: /*游戏者每次投掷两颗骨子,每个骰子是一个正方体,当骰子停止时,将每个骰子朝上的点数相加,在第一次投掷骰子时,如果所得到的和为7或11,那么游戏者为胜;所得和为2、3或12则输如和为4、5、6、8、9或 10,则此和为游戏者点数。如要想赢得胜利,必须继续投掷骰子,直到取和得自己的点数(也即规则2的点数)为止,如果投掷出的和为7,则为输(并非指第一次投掷的情况下)要 求main函数中可选择是继续还是退出游戏,统计并显示游戏获胜次数和输掉次数。*/#include<iostream>#include<ctime>using namespace std;void main() 阅读全文
posted @ 2012-11-22 23:08 ♂咱說 ろ算 阅读(386) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<algorithm>sortusing namespace std;template<class ElemType>class Array{ private: ElemType *elem; int size; public: Array(ElemType a[],int sz):elem(a),size(sz){}; ElemType Max(); ElemType Sum(); void Sort(); void Show();};template <class ElemType>Elem 阅读全文
posted @ 2012-11-22 23:06 ♂咱說 ろ算 阅读(157) 评论(0) 推荐(0) 编辑
摘要: //fraction.h#include"utility.h"#include<iostream.h>class Fraction{private: int nume; int deno; int Gcf(int m,int n);public: Fraction(int n=1,int d=1); virtual ~Fraction(){}; bool dight(char ch); void Reduction(); int GetNume(){return nume;} int GetDeno(){return deno;} void SetNume(in 阅读全文
posted @ 2012-11-22 23:05 ♂咱說 ろ算 阅读(244) 评论(0) 推荐(0) 编辑
摘要: /*设计一个日期类Date,包括年、月、日等私有成员。要求实现日期的基本运算,例如某日期加上天数或减去天数,两日期相减的天数等。实现要求:实现运算符加与减的重载*/#include<iostream>#include<string>#include<iomanip>#include<cmath>using namespace std;class Date{private: int year; int month; int day; static int sumDays;public: int monthDay(int year1,int mont 阅读全文
posted @ 2012-11-22 23:04 ♂咱說 ろ算 阅读(350) 评论(0) 推荐(0) 编辑
摘要: /*能够显示公元后任意年份的日历,日历以月份顺序排列,每月以星期顺序排列,类似于一般挂历上的格式。先以2000年1月1日周六作为推算起点来判定实现指定2000年后的日历再将起点日期改为公元元年一月一日是星期几注意判断闰年、月、周的判别*/#include<iostream>#include<iomanip>#include<cmath>using namespace std;class Date{private: int year;public: int monthDay(int year1,int month1); void setDate(); void 阅读全文
posted @ 2012-11-22 23:02 ♂咱說 ろ算 阅读(232) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<windows.h>using namespace std;typedef char TElemType ;typedef enum PointerTag{Link,Thread};typedef struct BiThrNode{ TElemType data; struct BiThrNode *lchild,*rchild; PointerTag LTag,RTag;}BiThrNode,*BiThrTree;void CreatTree(BiThrTree &T){ TElemType item; c 阅读全文
posted @ 2012-11-22 23:01 ♂咱說 ろ算 阅读(236) 评论(0) 推荐(0) 编辑
摘要: //main.cpp#include<iostream>using namespace std;typedef char TElemType;typedef struct node{ TElemType data; struct node *lchild; struct node *rchild;}BiTNode,*BinTree;BiTNode *creatBinTree(TElemType *VLR,TElemType *LVR,int n)//由中序序列和前序序列构造二叉树{ if(n==0) return NULL; int k=0; while(VLR[0]!=LVR[k 阅读全文
posted @ 2012-11-22 23:00 ♂咱說 ろ算 阅读(359) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<string>using namespace std;#define maxnum 100#define maxlength 10000typedef int ElemType;typedef int WType;typedef struct{ ElemType tu[maxnum][maxnum]; //邻接矩阵 string point[maxnum]; //顶点矩阵 int point_num; //顶点个数}Graph;void input(Graph &G){ cout<<"请 阅读全文
posted @ 2012-11-22 22:58 ♂咱說 ろ算 阅读(275) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<string>using namespace std;#define maxnum 100#define maxlength 10000typedef int ElemType;typedef int WType;typedef struct{ ElemType tu[maxnum][maxnum]; //邻接矩阵 string point[maxnum]; //顶点矩阵 int point_num; //顶点个数}Graph;void input(Graph &G){ cout<<"请 阅读全文
posted @ 2012-11-22 22:57 ♂咱說 ろ算 阅读(253) 评论(0) 推荐(0) 编辑
摘要: //graph.h#include<iostream>#include<cstdlib>#include<queue>using namespace std;#define maxVert 20#define maxWeight 10000typedef char VType;typedef double WType;typedef struct{ int numVetr,numEdges;//点和边的个数 VType *VertList;//点矩阵 WType **Edge;//邻接矩阵}Graph;void InitGraph(Graph &G) 阅读全文
posted @ 2012-11-22 22:56 ♂咱說 ろ算 阅读(225) 评论(0) 推荐(0) 编辑
摘要: //迷宫#include<iostream>#include<ctime>#include<windows.h>#include<fstream>using namespace std;struct offsets{ int a,b; char *dir;};struct node{ int x,y;};struct tag{ int x,y; char *dir;};class MiGong{private: int map[30][30];//地图矩阵 int mark[30][30];//标志矩阵 offsets move[4];//各个方 阅读全文
posted @ 2012-11-22 22:55 ♂咱說 ろ算 阅读(192) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<stack>using namespace std;const int MaxSize=100;int gcd(int a,int b){ int c; while(a%b!=0) { c=a%b; a=b; b=c; } return b;}int main(){ stack<int>S,Q; int num,i; cout<<"请输入有多少个数:"; cin>>num; int number[MaxSize]; for(i=0;i<num;i++) { 阅读全文
posted @ 2012-11-22 22:50 ♂咱說 ろ算 阅读(233) 评论(0) 推荐(0) 编辑