记录编号 |
405913 |
评测结果 |
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
题目名称 |
加法问题 |
最终得分 |
100 |
用户昵称 |
xzcxzc11 |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.000 s |
提交时间 |
2017-05-17 17:01:59 |
内存使用 |
0.00 MiB |
显示代码纯文本
#include<cstdio>
#include<iostream>
#include<iomanip>
using namespace std;
int ____();
int _=____();
int ____()
{
double __,___;
freopen("aplusb.in","r",stdin);
freopen("aplusb.out","w",stdout);
cin>>__>>___;
cout<<setiosflags(ios::fixed)<<setprecision(0)
<<__+___;
return 0;
}
int main()
{
return 0;
}
/*--------------------
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <iterator>
#include <windows.h>
#include <fstream>
#define DEBUG
using namespace std;
enum{magician=1,sodier=2,doctor=3};
class Skill
{
public:
enum skill_type{
type_attack=1,
type_improve=2,
type_recover=3
};
int value;
int cur_type;
Skill(int t_skill_type=-1,int t_value=-1);
};
class Player
{
enum attack_value {
atv_sodier = 700,
atv_magician = 1000,
atv_doctor = 500
};
enum improve_value {
imv_sodier = 2, //sodier protect
imv_magician = 3, //magician protect
imv_doctor = 5 //doctor protect
};
enum recover_value {
rev_sodier = 100,
rev_magician = 100,
rev_doctor = 500
};
enum secret_value {
sev_sodier = 1400,
sev_magician = 2000,
sev_doctor = 1000,
secret_enable = 4
};
enum base_health {
bh_sodier=20000,
bh_magician=15000,
bh_doctor=10000
};
enum skill_type{
type_attack = 1,
type_improve = 2,
type_recover = 3
};
int number;
Skill attack, improve, recover, secret_skill;//攻击,提升属性,恢复,秘技
int job;
string name;
int health;
bool alive;
int mp;
int imp_pro;
int max_health;
string job_name;
public:
Player(int t_number, string t_name, int t_job);
Player()
{
alive = true;
number = -1;
job = -1;
health = -1;
mp = -1;
name = "error";
}
int get_number() { return number; }
int get_job() { return job; }
string get_name() { return name; }
int get_health() { return health; }
bool is_alive() { return alive; }
void harm_self(int t_val);
void health_self(int t_val);
void protect_self(int t_val);
ostream & attack_it(ostream & t_out, Player & t_target);
ostream & improve_it(ostream & t_out, Player & t_target);
ostream & recover_it(ostream & t_out, Player & t_target);
ostream & secret_skill_it(ostream & t_out, Player & t_target);
bool can_secret_skill() { return (mp>=secret_enable); }
friend ostream & operator<<(ostream & t_out, const Player & t_player);
};
void act_it(Skill & t_skill,Player & t_target);
ostream & operator<<(ostream & t_out, const Player & t_player);
Player::Player(int t_number, string t_name, int t_job)
{
alive = true;
number = t_number;
job = t_job;
name = t_name;
mp = 0;
imp_pro = 0;
if (job == magician)
{
job_name="法师";
max_health = bh_magician;
health = bh_magician;
attack = Skill(type_attack, atv_magician);
improve = Skill(type_improve, imv_magician);
recover = Skill(type_recover, rev_magician);
secret_skill = Skill(type_attack, sev_magician);
return;
}
else if (job == sodier)
{
job_name="战士";
max_health = bh_sodier;
health = bh_sodier;
attack = Skill(type_attack, atv_sodier);
improve = Skill(type_improve, imv_sodier);
recover = Skill(type_recover, rev_sodier);
secret_skill = Skill(type_attack, sev_sodier);
return;
}
else if (job == doctor)
{
job_name="医生";
max_health = bh_doctor;
health = bh_doctor;
attack = Skill(type_attack, atv_doctor);
improve = Skill(type_improve, imv_doctor);
recover = Skill(type_recover, rev_doctor);
secret_skill = Skill(type_attack, sev_doctor);
return;
}
}
void Player::harm_self(int t_val)
{
int real_val = t_val*(1 - imp_pro*0.01);
if (health - real_val <= 0)
{
health = 0;
alive = false;
return;
}
health -= real_val;
}
void Player::health_self(int t_val)
{
int real_value = t_val;
if (health + real_value >= max_health)
{
health = max_health;
return;
}
health += real_value;
}
void Player::protect_self(int t_val)
{
const int max_imp_pro=25;
if (imp_pro == max_imp_pro) return;
imp_pro += t_val;
}
ostream & Player::attack_it(ostream & t_out, Player & t_target)
{
if (!t_target.is_alive())
{
t_out << "动作对象已经死亡!" << endl;
return t_out;
}
act_it(attack, t_target);
t_out << t_target.name << "被" << name << "的普通攻击技能击中" << endl;
if (!t_target.is_alive())
{
t_out << t_target.name << "已死亡!" << endl;
t_out << "葛伯瑟祝您身体健康!" << endl;
}
else
{
t_out << t_target.name << "剩余血量: " << t_target.get_health() << endl;
}
++mp;
return t_out;
}
ostream & Player::improve_it(ostream & t_out, Player & t_target)
{
if (!t_target.is_alive())
{
t_out << "动作对象已经死亡!" << endl;
return t_out;
}
act_it(improve, t_target);
t_out << name << "对" << t_target.name << "施加防护提升!" << endl;
t_out << "葛董祝您游戏愉快!" << endl;
++mp;
return t_out;
}
ostream & Player::recover_it(ostream & t_out, Player & t_target)
{
if (!t_target.is_alive())
{
t_out << "动作对象已经死亡!" << endl;
return t_out;
}
act_it(recover, t_target);
t_out << name << "为" << t_target.name << "恢复生命!" << endl;
t_out << t_target.name << "剩余生命为: " << t_target.get_health() << endl;
++mp;
return t_out;
}
ostream & Player::secret_skill_it(ostream & t_out, Player & t_target)
{
if (!t_target.is_alive())
{
t_out << "动作对象已经死亡!" << endl;
return t_out;
}
if (mp < secret_enable)
{
t_out << name << "没有足够的mp对"
<< t_target.name << "发动秘技!" << endl;
return t_out;
}
act_it(secret_skill, t_target);
t_out << name << "对" << t_target.name << "发动秘技!" << endl
<< t_target.name << "开始方了! 感到害怕!" << endl;
if (!t_target.is_alive())
{
t_out << t_target.name << "已死亡!" << endl;
t_out << "葛伯瑟祝您身体健康!" << endl;
}
else
{
t_out << t_target.name << "剩余血量: " << t_target.get_health() << endl;
}
mp -= secret_enable;
return t_out;
}
Skill::Skill(int t_skill_type, int t_value)
{
value = t_value;
cur_type = t_skill_type;
}
ostream & operator<<(ostream & t_out, const Player & t_player)
{
const int line_length = 50;
for (int i = 0; i < line_length; ++i)
t_out << "=";
t_out << endl;
t_out << "ID: " << t_player.number << " "
<< "用户名: " << t_player.name << " "
<< "职业: " << t_player.job_name << " "
<< "MP(魔法): " << t_player.mp << " "
<< endl;
t_out << "生命值: " << t_player.health << " "
<< "防御力: " << t_player.imp_pro << " "
<< endl;
for (int i = 0; i < line_length; ++i)
t_out << "=";
return t_out;
}
void act_it(Skill & t_skill, Player & t_target)
{
if (t_skill.cur_type == t_skill.type_attack)
{
t_target.harm_self(t_skill.value);
return;
}
if (t_skill.cur_type == t_skill.type_improve)
{
t_target.protect_self(t_skill.value);
return;
}
if (t_skill.cur_type == t_skill.type_recover)
{
t_target.health_self(t_skill.value);
return;
}
}
enum command {
cmd_attack = 1, cmd_improve = 2, cmd_recover = 3, cmd_secret_skill = 4
};
struct Node
{
int command;
vector<Player>::iterator cur_player;
vector<Player>::iterator target;
Node(vector<Player>::iterator t_cur_player,
int t_command, vector<Player>::iterator t_target);
#ifndef DEBUG
Node() = default;
#endif
};
class Main_game
{
vector<Player> players;
int number;
queue<Node> waiting_queue;
//ostream & out;
//istream & in;
public:
void display_player(vector<Player> & players)
{
system("cls");
for(vector<Player>::iterator it=players.begin();it!=players.end();++it)
{
if (it->is_alive())
{
cout << *it << endl;
}
}
cout << endl << endl;
}
void Read(istream & t_in,ostream & t_out);
void work(istream & t_in,ostream & t_out);
void print_result(ostream & t_out);
};
Node::Node(vector<Player>::iterator t_cur_player, int t_command, vector<Player>::iterator t_target)
{
cur_player = t_cur_player;
command = t_command;
target = t_target;
}
void Main_game::Read(istream & t_in, ostream & t_out)
{
while(1)
{
t_out << "请输入玩家数量" << endl;
t_in >> number;
if(number>1)
{
break;
}
t_out<<"输入有误! 请输入2~8之间的整数!"<<endl;
}
string t_name;
int t_job;
for (int i = 0; i < number; ++i)
{
while (1)
{
t_out << "请输入"<<i<<"号玩家名和职业,用一个空格分隔,职业用数字表示: " << endl
<< "法师(1) 战士(2) 医师(3)" << endl;
t_in >> t_name >> t_job;
if (t_job == magician || t_job == sodier || t_job == doctor)
{
break;
}
t_out << "职业输入有误,请重新输入." << endl;
}
players.push_back(Player(i, t_name, t_job));
}
}
void Main_game::work(istream & t_in,ostream & t_out)
{
int turn =1;
while (number!=1)
{
t_out<<"第"<<turn<<"回合:"<<endl;
for (vector<Player>::iterator it1=players.begin();it1!=players.end();++it1)
{
if(!it1->is_alive())
{
continue;
}
int target_number,command;
display_player(players);
while(1)
{
t_out<<"轮到"<<it1-players.begin()<<"号玩家:"<<endl;
t_out<<"请输入指令编号和目标编号:"<<endl
<<"攻击(1), 防御(2), 回血(3),秘技(4)"<<endl
<<"秘技仅当MP>=4时才可发动"<<endl;
t_in>>command>>target_number;
if(target_number<players.size()&&(players.begin()+target_number)->is_alive())
{
break;
}
t_out<<"输入有误!"<<endl;
}
waiting_queue.push(Node(it1,command,players.begin()+target_number));
}
while (waiting_queue.empty()!=true)
{
Node cur=waiting_queue.front();
waiting_queue.pop();
if(!(cur.target->is_alive()))
continue;
if(cur.command==cmd_attack)
{
cur.cur_player->attack_it(t_out,*(cur.target));
if(!cur.target->is_alive())
--number;
}
else if(cur.command==cmd_improve)
{
cur.cur_player->improve_it(t_out,*(cur.target));
}
else if(cur.command==cmd_recover)
{
cur.cur_player->recover_it(t_out,*(cur.target));
}
else if(cur.command==cmd_secret_skill)
{
cur.cur_player->secret_skill_it(t_out,*(cur.target));
if(!cur.target->is_alive())
--number;
}
Sleep(1000);
}
system("pause");
t_out<<endl;
}
}
void Main_game::print_result(ostream & t_out)
{
Player player_alive;
for (vector<Player>::iterator it=players.begin();it!=players.end();++it)
{
if(it->is_alive())
{
t_out<<"恭喜 玩家"<<it->get_name()<<"获得了胜利!"<<endl;
t_out<<"整盘游戏结束"<<endl;
}
}
}
//--------------The following is function main()---------------------
int main()
{
ifstream fin("game.in");
#ifdef DEBUG
Main_game main_game;
main_game.Read(fin,cout);
main_game.work(cin,cout);
main_game.print_result(cout);
return 0;
#endif // DEBUG
}
//------------The end of function main()-----------------------------
--------------------*/