2012年3月19日

hdu 3081 Marriage Match II

摘要: Sample Input14 5 21 1233 24 2441 42 3结合输入数据讲题意,1,就是一组输入数据,4表示有2 * 4个人,女生编号为1-4, 男生编号也为1-4,5表示下面接下来5对关系是没有吵过架的,2表示为有2对女生女生是好朋友的关系,也就是最后输入的那两行题目是要我们求每个女生找一个男生,并且这个男生没有和她吵过架,如果她朋友没有跟这个男生吵过架也可以。还有就是女生之间的朋友关系可以传递。但是不能找以前她已经找过的男生。。当每个女生找到一个男生后,这个游戏就算玩了一次,然后接着继续玩。要我们解决的问题是,这个游戏最多可以玩几圈。算法:1.并查集因为女生之间的朋友关系可以 阅读全文

posted @ 2012-03-19 22:54 more think, more gains 阅读(292) 评论(0) 推荐(0) 编辑

public 继承

摘要: View Code #include <iostream>#include <string>#include <cstdlib>using namespace std;class student{ public: student( ) { name = "tang"; num = "104080219"; sex = "M"; } void display( ); void input( ); private: string name; string num; string sex;};class 阅读全文

posted @ 2012-03-19 15:25 more think, more gains 阅读(161) 评论(0) 推荐(0) 编辑

c++ 运算符重载

摘要: View Code /*运算符重载,类型转换函数,转换构造函数无参默认构造函数,带参初始化构造函数,*/#include <iostream.h>//#include <iostream>#include <cstdlib>//using namespace std;class Complex{ public: Complex( ) { real = 0; imag = 0; } //无参默认构造函数 //Complex(double r) { real = r; imag = 0;} 转换构造函数 Complex(double r, double i) { 阅读全文

posted @ 2012-03-19 14:41 more think, more gains 阅读(123) 评论(0) 推荐(0) 编辑

导航