自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(37)
  • 收藏
  • 关注

原创 未重构的 魔兽世界终极版

#include #include #include #include #include #include #include using namespace std;class Headquarter;class Iceman;class Warrior;class Ninja;class Wolf;class Lion;class Dragon;class Weap

2012-04-22 17:07:53 3598 1

原创 PKU-程序设计实习-Myistream_iterator

#include #include #include using namespace std;templateclass CMyistream_iterator{public: CMyistream_iterator(istream& istrm_): istrm(istrm_) { istrm >> val; }; void operator ++ (int) {

2012-04-22 17:06:17 1383

原创 PKU-程序设计实习-MySort函数

#include #include #include using namespace std;void mysort(void* inputArray, const int nInput, const int dataSize, int cmpFunc(const void* elem1, const void* elem2)){ char* input = (char*)input

2012-04-22 17:04:48 1150

原创 10000以内的阶乘

#include #include #include using namespace std;/* 算法很水的,不过改良方向大概就是每四位算一个之类的东西了。。参考麦森数 */int getWeishu(int n){ double weishu = 0; for(int i = 2; i <= n; i++) { weishu += log10

2012-04-03 16:27:23 493

原创 八皇后问题

#include using namespace std;int line[9] = {1};int Left[16] = {1};int Right[16] = {1};int board[9][9] = {0};int num = 0;void print(){ cout << "No. " << num << endl; for(int i = 1; i

2012-04-03 16:26:18 443

原创 钉子和小球

#include #include using namespace std; char graph[60][60] ; long long result[60][60] ; long long gcd( long long a ,long long b ) { if(b == 0) return a ; else retu

2012-04-03 16:25:30 611 3

原创 字符环

#include #include using namespace std;int getMaxCycle(string& s1, string& s2){ int max = 0; for(int i = 0; i < s1.length() / 2; i++) { for(int j = 1; j <= s1.length() / 2 + 1;

2012-04-03 16:25:00 1709

原创 显示器

#include#include#includeusing namespace std;char map[10][16] ={ " - | | | | - ", " | | ", " - | - | - ", " - | - | - ", " | | - | ", " - | -

2012-04-03 16:24:05 478

原创 统计单词数

#include #include #include #include #include #include using namespace std;/* 耗时什么的,完全不在乎了,已经被搞吐了 */void stolower(string& str){ for(int i = 0; i < str.size(); i++) if(isalpha(str[i

2012-04-03 16:20:17 519

原创 GPA排名系统

#include #include using namespace std;int main(){ int m, n; char lesson[22][22]; scanf("%d%d", &m, &n); for(int i = 0; i < n; i++) { scanf("%s", lesson[i]); }

2012-04-03 16:18:48 989

原创 3月25日更新手记

0. 今天要处理的问题0.1 为魔兽世界一备战的轮换生产武士改写为取余的方式0.2 由Moien同学发现我的位图扭转是镜面转换,的确如此,谁叫图片数据反着扫呢,所以要修改0.3 为0.2编写文档0.4 为位图扭转改写为命令行的模式,最好也支持无参的调用1. 改正位图扭转方向发生错误的问题,见评论2. 将位图扭转改写为命令行模式,支持无参的调用3. 博客名称改回T

2012-03-25 11:11:40 417

原创 3月24日更新手记

1. 将多态作业中的猥琐析构函数用虚析构函数处理(第4题)2. 删除错误的bmp位图扭转源代码,就是昨天发的那个3.为位图作业添加了文档本帖每日持续更新

2012-03-24 19:41:00 481

原创 PKU-文件操作作业-BMP图像文件旋转

解题思路:1.待处理的对象:待处理的对象是BMP位图,实际上只是一种类型的文件流,和字符流什么的没有区别,这次练习的核心是为了锻炼出惊人的操作读写流的能力,所以,就将其当作01流就可以了。因此关于BMP最重要的就是要理解流的什么地方是什么,实际上文档上已经说得比较详细了。在此不再赘述BMP的基本理论,只重点讨论24位和32位位图。这里的位,实际上就是指一个像素格所占的位数(bit),需要知

2012-03-24 13:36:03 4596 8

原创 PKU-多态作业-程设hw04

1)D::FunB::FunD::FunnBVal=2nBVal=24nDval=8B::FunnBval=122)A::funcC::fundA::fund3)B& p4)class A{public: virtual ~A() { cout << "destructor A" << endl; }; // 所谓的虚析构函数:先调用子类的,再调用自己的

2012-03-23 17:54:39 1132

原创 为了方便大家。。(多态作业source)

下面的内容严重剧透……不喜误入事实上,我找到了一个很简单的让pdf可以被复制(你懂的)的办法在此之前,我强烈建议同学们用来对答案而不是生成答案所以,就贡献出来吧……千万不要告诉老师或者是助教啊// 请同学们24小时之内删除!1)看程序写结果:class B {private:int nBVal;public:void Print(

2012-03-20 22:01:36 781

原创 PKU-MyString类作业-程设hw04-MyString1.cpp(继承)

class MyString: public string{public: MyString(const char* str):string(str){}; MyString():string(){}; MyString(string str):string(str){}; MyString operator () (int i, int j) { return substr(i

2012-03-20 21:55:58 1309

原创 麦森数

// 这道题的难点在于容易超时,// 实际上一下算法是做了一些参考的// 核心就是1, 位运算// 2, 将四位数作为一个计算单位// 3, 以及一个公式简便地计算结果的位数#include #include #include using namespace std;int main(){ int num[125] = {0}; int l

2012-03-17 20:40:56 651

原创 算24

// 唉,写得真TM丑#include #include using namespace std;bool calcu_2(double a, double b){ if(fabs(a + b - 24) < 1e-6 || fabs(a - b - 24) < 1e-6 || fabs(b - a - 24) < 1e-6 || fabs(a * b -24) < 1

2012-03-17 20:40:01 376

原创 生理周期

// 这道题的难点什么的记不清楚了,poj上有一个讨论,给了一些奇葩数据// http://poj.org/bbs?problem_id=1006#includeusing namespace std;int main(){ int p, e, i, d; int Case = 1; while(cin >> p >> e >> i >> d)

2012-03-17 20:38:41 486

原创 确定进制

// 上学期计概题了#include#includeusing namespace std;int main(){ int n; cin >> n; for (;n >= 1; n --) { int B, i, j, k; int p, q, r, found = 0; int P[11] = {0}, Q[11] = {0}, R[11] = {0}; c

2012-03-17 20:35:26 468

原创 外星人翻译用数字转换模块

#include #include #include using namespace std;int main(){ map words; // STL, 建立string到int的映射 words["zero"] = 0; words["one"] = 1; words["two"] = 2; words["three"] =

2012-03-17 20:33:50 600

原创 有未知数的表达式

#include #include #include using namespace std;char buf[35];int result;int main(){ int calcu(int i, int j); memset(buf, 0, sizeof(buf)); while(cin.getline(buf, 35)) { result = 0; int i

2012-03-17 20:32:01 1072

原创 城堡问题

// 上学期怎么这么傻逼啊(吐槽)#include using namespace std;// 建立一个room类,存墙壁和是否走过的信息,类或结构体都好class room{public: room() { e = n = s = w = 0; walked = 0; } int e, n, s, w, walked;}room[60][60];int m

2012-03-17 20:31:23 311

原创 垂直直方图

#include #include #include using namespace std;int main(){ int alpha[26] = {0}; char buf[80 + 10] = {}; for(int i = 0; i < 4; i++) { cin.getline(buf, 81); for(int j = 0; j < strlen(buf);

2012-03-17 20:29:58 1042

原创 PKU-MyInt和HugeInt作业-程设hw03

//按照作业中题序,空格序1)MyInt& operator – (int a){ this->nVal -= a;    return *this;}2)friend Ostream& operator << (Ostream& output, const Point& p)Ostream&Ostream& outputoutput <<

2012-03-10 22:23:07 484

原创 PKU-静态成员作业-程设hw03

// 按照作业中题序,空格序1)41 // 题目中调用了一次函数,在返回对象的时候从底层栈中将此对象复制构造给主函数中变量后,调用了此对象的析构函数,于是使静态成员被减少一次2)// 这道题还是函数调用导致了复制构造函数的调用,在传参和 return 的时候都被调用一次92253)int n = 0int& val4)// 这里用了a

2012-03-10 22:19:21 495

原创 PKU-MyString类作业-程设hw04-MyString1.cpp(重现)

// 仅贴类的部分,没什么难点,重载吧class MyString{public: MyString() { s = new char[1]; s[0] = 0; }; MyString(const char* str) { s = new char[strlen(str) + 1]; strcpy(s, str); } MyString(MyString& s

2012-03-09 21:24:51 604

原创 MyInt

#include using namespace std;class MyInt { int nVal; public: MyInt( int n) { nVal = n ;} int ReturnVal() { return nVal;} MyInt& operator - (int a) { this->nVal -= a; return * th

2012-03-09 17:55:46 966

原创 HugeInt

#include #include #include #include using std::ostream; using std::cout; using std::cin; using std::endl; const int MAX = 110; class CHugeInt{public: CHugeInt() { length = MAX; m

2012-03-09 17:44:19 1501

原创 魔兽世界之二武器

#include #include #include #include #include using namespace std;int dHP, iHP, lHP, nHP, wHP; // 全局魔兽初始生命const int MAXN = 1000 + 10;class Headquater;class Iceman;class Warrior;class Ninj

2012-03-09 00:15:37 1257 3

原创 计算对数

#include #include #include const int MAXN = 300;using namespace std;/* 大数类,重载流运算,== 运算 */class Bigint{public: friend istream& operator >> (istream& input, Bigint& b); friend ostream

2012-03-06 19:14:00 470

原创 宇航员

#includeusing namespace std;int main(){ char direct[10]; int rev[6] = {3, 4, 5, 0, 1, 2}; // 数组 rev 储存 6 个方向的反向 int f, l, u; // 分别是前,左,上的方向代号 int

2012-03-06 19:10:19 403

原创 树根

#include #include using namespace std;const int MAXN = 1000 + 10;int main(){ char number[MAXN] = {}; while(cin >> number) { if(!strcmp(number, "0")) { break; } int root = 0; fo

2012-03-06 19:05:36 482

原创 词典

#include #include #include #include using namespace std;//程序引用了c++标准库的类模板 map,这个模板貌似是基于散列算法的(由于不想自己写hash……),不过程序效率不太高啦int main(){ map dic; // 建立string 到 string 的映射 dic string translate

2012-03-06 19:04:39 309

原创 特殊日历

#include using namespace std;bool isleap(int year){ if (year % 4 != 0 || (year % 100 == 0 && year % 400 != 0)) return false; else return true;}int main(){ double k

2012-03-06 18:59:42 508

原创 魔兽世界之一备战

#include #include #include #include #include using namespace std;int dHP, iHP, lHP, nHP, wHP; // 全局魔兽初始生命/* class: 游戏钟表 */class Clock{public: Clock(){ hour = 0; } void tick()

2012-03-06 18:58:04 2647

原创 循环数

#include #include using namespace std;const int MAXN = 100;int main(){ bool is_cyclic(char origin[], char detect[]); // is_cyclic() => 判断两个数字串是否成环后一致 char number[MAXN] = {};

2012-03-06 17:39:25 604

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除