为啥ce
2025-10-03 11:30:39
发布于:广东
#include <windows.h>
#include <bits/stdc++.h>
using namespace std;
// ==================== 用户自定义部分 ====================
// 循环宏定义
#define fw(l, r, i, j) for(int i = l, END##i = r; i <= END##i; i += j)
#define fs(r, l, i, j) for(int i = r, END##i = l; i >= END##i; i -= j)
// 内存设置宏
#define ms(arr, val) memset(arr, val, sizeof(arr))
// 常用类型别名
typedef long long ll;
typedef double d;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef const ll coll;
// 输入输出优化函数
void oi(void) {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
// 文件重定向函数
void fr(ll x, str s) {
if(x == 1) {
str s1 = s + ".in", s2 = s + ".out";
freopen(s1.c_str(), "r", stdin);
freopen(s2.c_str(), "w", stdout);
} else if(x == 2) {
fclose(stdin);
fclose(stdout);
}
}
coll ARMSS = 10;
ll h = 100, gold;
bool timesfled = 0;
void cls() {
system("pause & cls");
}
struct Arm {
ll grade, durability;
};
struct ARM : Arm {
str name;
bool f;
};
ll armsum = 4;
struct ENEMY_DATA {
str name;
ll hp, grade;
};
class ENEMY;
class ARMS {
private:
str name;
ll grade, durability;
bool f;
public:
ARMS(str name, ll grade, ll durability, bool f) {
this->name = name;
this->grade = grade;
this->durability = durability;
this->f = f;
}
ARM data_viewing() {
return {this->grade, this->durability, this->name, this->f};
}
void attack(ENEMY& a);
void arm_sell() {
f = 0;
}
};
class ENEMY {
private:
str name;
ll hp, grade;
public:
void hurt(ll damage) {
this->hp = max(this->hp - damage, 0LL);
}
ENEMY(str name, ll hp, ll grade) {
this->name = name;
this->hp = hp;
this->grade = grade;
}
bool die() {
return this->hp <= 0;
}
ENEMY_DATA data_viewing() {
return {this->name, this->hp, this->grade};
}
void attack();
};
void ARMS::attack(ENEMY& a) {
if(this->durability >= 1) {
auto enemy_before = a.data_viewing();
a.hurt(this->grade);
this->durability--;
auto enemy_after = a.data_viewing();
printf("使用%s对%s造成%lld点伤害\n", this->name.c_str(),
enemy_after.name.c_str(), min(this->grade, enemy_before.hp));
printf("%s还剩%lld点耐久\n", this->name.c_str(), this->durability);
printf("%s还剩%lld点血\n", enemy_after.name.c_str(), enemy_after.hp);
} else {
printf("耐久不足!\n");
}
}
void ENEMY::attack() {
h = max(h - this->grade, 0LL);
printf("收到来自%s的%lld点伤害,还剩%lld点血。\n",
this->name.c_str(), grade, h);
}
bool player_die() {
return h <= 0;
}
ll end_check(ENEMY& a) {
if(player_die()) return 2;
if(a.die()) return 1;
return 0;
}
vector<ARMS> arm;
void merchant();
void shelf();
void arm_sell();
void armsshop() {
printf("欢迎进入武器市场……\n");
ll num;
printf("1.奸商\n");
printf("2.武器锻造商\n");
printf("3.群众\n");
cin >> num;
switch(num) {
case 1:
merchant();
break;
case 2:
// 武器锻造商功能待实现
printf("武器锻造商功能暂未开放\n");
break;
case 3:
// 群众功能待实现
printf("群众功能暂未开放\n");
break;
default:
printf("输入错误!\n");
break;
}
}
void merchant() {
printf("欢迎光临本店,要啥自己挑。\n");
printf("1.二手武器货架\n");
printf("2.武器贩卖\n");
ll num;
cin >> num;
switch(num) {
case 1:
shelf();
break;
case 2:
arm_sell();
break;
default:
printf("输入错误!\n");
break;
}
}
void shelf() {
ll Size = rand() % 4 + 1;
vector<Arm> ARm;
for(ll i = 0; i < Size; i++) {
ARm.push_back({rand() % 50 + 3, rand() % 100 + 10});
}
tiaoxuanwuqi:
for(ll i = 0; i < Size; i++) {
printf("%lld.伤害%lld 耐久%lld\n", i + 1, ARm[i].grade, ARm[i].durability);
}
ll num;
cin >> num;
if(num > Size || num < 1) {
printf("无效的选择!\n");
cls();
goto tiaoxuanwuqi;
}
printf("1.跑路\n");
printf("2.老老实实付钱\n");
ll nu;
cin >> nu;
switch(nu) {
case 1:
{
ll probability = rand() % 100;
if(probability >= 90) {
printf("跑路成功!牛逼!\n");
} else {
printf("敢跑路!!!\n");
if(timesfled) {
printf("还来,上次没打你是吧!!!\n");
}
ll probability2 = rand() % 100;
if(probability2 < 95 || timesfled) {
ll damage = timesfled ? 100LL : (rand() % 80 + 10);
h = max(h - damage, 0LL);
printf("被肘击了,扣%lld点血。还剩%lld点血。\n", damage, h);
} else {
printf("放你一马!\n");
}
timesfled = true;
}
}
break;
case 2:
{
Arm selected = ARm[num - 1];
ll grade = selected.grade, durability = selected.durability;
ll money = grade * 2 + durability * 3 + rand() % 100;
printf("给钱!%lld金币!\n", money);
printf("1.付钱\n");
printf("2.讲价\n");
ll choice;
cin >> choice;
switch(choice) {
case 1:
if(gold < money) {
printf("没钱还来买!!!滚!\n");
return;
}
gold -= money;
printf("花费了%lld点金币!\n", money);
cls();
printf("为自己的武器取个名字吧!");
str name;
cin >> name;
arm.push_back(ARMS(name, grade, durability, true));
printf("购买成功!\n");
break;
case 2:
printf("讲价功能暂未实现\n");
break;
default:
printf("输入错误!\n");
break;
}
}
break;
default:
printf("输入错误!\n");
break;
}
}
void arm_sell() {
if(arm.empty()) {
printf("你没有武器可卖!\n");
return;
}
for(ll i = 0; i < arm.size(); i++) {
auto ar = arm[i].data_viewing();
printf("%lld.%s 耐久%lld 伤害%lld\n", i + 1, ar.name.c_str(), ar.durability, ar.grade);
}
printf("卖哪个赶紧挑!\n");
ll num;
cin >> num;
num--;
if(num >= arm.size() || num < 0) {
printf("无效的选择!\n");
} else if(num == 0 && arm.size() > 0) {
printf("空手指你还卖,滚!\n");
} else {
auto ar = arm[num].data_viewing();
ll money = ar.grade * 2 + ar.durability * 3 - rand() % 100;
money = max(money, 0LL); // 确保不会出现负数
printf("%lld金币,拿了赶紧走!\n", money);
gold += money;
arm.erase(arm.begin() + num);
printf("出售成功!\n");
}
}
int main() {
srand(time(0));
gold = 1000000000000;
armsshop();
return 0;
}
全部评论 1
不适隔门测评机你用window.h你不CE谁CE
2025-10-03 来自 浙江
0
















有帮助,赞一个