程序设计实习 魔兽世界终极版 注意及代码~

这篇博客分享了魔兽世界终极版程序设计实习的挑战,强调看清题目和理解逻辑的重要性。作者建议先尝试行军版题目,并提供了AC代码链接。遇到WA的情况,推荐使用UltraCompare软件进行代码对比找出问题。文章详细讲解了处理升旗、武士奖励、行军、炸弹使用和射箭等关键点,以及解决这些问题的策略。最后,给出了通过测试的简洁代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://cxsjsx.openjudge.cn/warcraftpractice/1/

 

这个题,,怎么说呢,大bug不解释。。

超级模拟有木有。。

 

第一:看清题目!!!!!!

第二,如果你是直接从装备跳到终极版的话,建议你先去做一做行军

传送门: http://poj.grids.cn/practice/3750/ 和http://poj.org/problem?id=3760

难度较小。

行军版我的AC代码:

http://blog.youkuaiyun.com/ckcz123/article/details/8729135 

第三,如果你总是总是WA的话,给你一个方法。

去下一个UltraCompare软件,
下载地址 ------> http://www.huacolor.com/soft/69625.html
这个东西可以将两个文本文档进行比较。

将你的所有输出保存在一个txt文件中 (fprintf总会吧)
然后复制下面我AC的代码,也保存在一个文件中,直接相比较,就能找到问题在哪。
多试几组数据,随便输入,找个几次一定可以找到问题所在。

 

关于其中的几点要说两句。

 

第一,在升旗的问题处理上。注意平局的话也不算连胜。

第二,武士应该是先获得司令部奖励的生命元,司令部再获得生命元,所以应该先保存起来,司令部能在这一轮中得到多少生命元,执行奖励,司令部的生命元再加。

第三,关于行军问题,这就和数组中的每个元素向前一个或者向后一个类似。

第四,在估计是否使用bomb时一定要注意,一击能否杀死敌人,或者敌人是否是ninjia不会反击的!

第五,也是最麻烦的一点,就是射箭问题。因为射箭后杀死敌人,如果其城市有己方,仍算己方胜利,武士仍会欢呼等。所以我的方法是,如果射箭杀死敌人的话不立刻将敌人的指针变为NULL,而是先将其hp变为0,即“假死状态”,然后再在beat函数前加一个判断。要注意双方都被射死的情况!

 

大意就这么多。衷心希望每个人都能尽快AC。

 

下面是我的AC代码,没加任何注释。不过函数以及变量的命名应该还是蛮清晰的。

 

516K,30MS,14757B

 

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

const int DRAGON=0,NINJIA=1,ICEMAN=2,LION=3,WOLF=4;
const int now_order[2][5]={
  
  {2,3,4,1,0},{3,0,1,2,4}};
const char* s[2]={"red","blue"};
const char* ss[5]={"dragon","ninja","iceman","lion","wolf"};
const char* sss[3]={"sword","bomb","arrow"};
int need[5],order[2],number[2],_attack[5],worriors_temp[2],now_time,city_sum,total[2],arrow_attack,loyalty_minus;
bool head_num[2],game_over,last_color[2];

class sword
{
private:
	int force;
public:
	sword(int x):force(x) {}
	void used() {force=force*0.8;}
	bool is_deserted() {return (force==0);}
	int get_force() {return force;}
};
class arrow
{
private:
	int used_times;
	int force;
public:
	arrow(int x,int y):used_times(x),force(y) {}
	void used() {used_times--;}
	bool is_deserted() {return (used_times==0);}
	int get_force() {return force;}
	int get_used_time() {return used_times;}
};
class worriors
{
public:
	worriors(int,int,int);
	~worriors()
	{
		if (_sword!=NULL) delete _sword;
		if (_arrow!=NULL) delete _arrow;
	}
	void get_hp(int a) {hp+=a;}
	virtual void happy(int) {}
	virtual void change_morale(int) {}
	virtual bool will_escape() {return false;}
	virtual void minus_loyalty() {}
	friend class city;
protected:
	int type;
	int id;
	int hp;
	int color;
	int attack;
	sword* _sword;
	arrow* _arrow;
	bool has_bomb;
};
class dragon: public worriors
{
private:
	double morale;
public:
	dragon(int _color,int _id,int _type):worriors(_color,_id,_type)
	{
		morale=(double)total[_color]/(double)need[0];
		printf("Its morale is %.2lf\n",morale);
	}
	void happy(int _id)
	{
		if (morale>0.8)
			printf("%.3d:40 %s dragon %d yelled in city %d\n",now_time,s[color],id,_id);
	}
	v
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值