为啥CE
2025-10-05 13:50:14
发布于:浙江
本问题由@小羊好吃-Huawe505解决了!!!
#本帖即将删除
#include <windows.h>
#include<bits/stdc++.h>
// ==================== 用户自定义部分 ====================
using namespace std; // 使用标准命名空间
// 循环宏定义
// 正向循环:从 l 到 r,步长为 j
#define fw(l,r,i,j)for(int i=l,END##i=r;i<=END##i;i+=j)
// 反向循环:从 r 到 l,步长为 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; // 64位有符号整数
typedef double d; // 双精度浮点数
typedef unsigned long long ull; // 64位无符号整数
typedef char ch; // 字符
typedef string str; // 字符串
typedef const ll coll; // 常量64位整数
// 输入输出优化函数
void oi(void) {
ios::sync_with_stdio(0); // 关闭C++标准流与C标准流的同步
cin.tie(0); // 解除cin与cout的绑定
cout.tie(0); // 解除cout的绑定
}
// 文件重定向函数
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
{
str name;
ll hp,grade;
};
class ENEMY;
class ARMS
{
/*
public(公有)
private(私有)
protected(保护)
*/
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 dataviewing()//1.输出武器信息
{
return {this->grade,this->durability,this->name,this->f};
//printf("武器名称:%s\n武器伤害:%lld\n武器耐久:%lld\n\n",name.c_str(),grade,durability);
}
void attack(ENEMY& a);
void ARMsell()
{
f=0;
}
};
class ENEMY
{
private:
str name;
ll hp,grade;
public:
void hurt(ll hp)
{
this->hp=max(this->hp-hp,0LL);
}
ENEMY(str name,ll hp,ll grade)
{
this->name=name;
this->hp=hp;
this->grade=grade;
}
bool die()
{
if(this->hp<=0)
{
return 1;
}
return 0;
}
ENEMy dataviewing()
{
return {this->name,this->hp,this->grade};
}
void attack();
};
void ARMS::attack(ENEMY& a)
{
if(this->durability>=1)
{
auto c=a.dataviewing();
a.hurt(this->grade);
this->durability--;
ENEMy b=a.dataviewing();
printf("使用%s对%s造成%lld点伤害\n%s还剩%lld点耐久\n%s还剩%lld点血\n",this->name.c_str(),b.name.c_str(),min(this->grade,c.hp),this->name.c_str(),this->durability,b.name.c_str(),b.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 die()
{
if(h<=0)return 1;
return 0;
}
ll endcheck(ENEMY a)//0无事发生 1敌人死亡 2玩家死亡
{
if(die())return 2;
if(a.die())return 1;
return 0;
}
vector<ARMS>arm;
void merchant();
void shelf();
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:
break;
case 3:
break;
default:
printf("还想干嘛!\n");
break;
}
}
void armsell();
void merchant()
{
printf("欢迎光临本店,要啥自己挑。\n");
printf("1.二手武器货架\n");
printf("2.武器贩卖\n");
ll num;
cin>>num;
switch(num)
{
case 1:
shelf();
break;
case 2:
armsell();
break;
case 3:
break;
default:
printf("还想干嘛!\n");
break;
}
}
void shelf()
{
ll Size=rand()%4+1,num;
vector<Arm>ARm(1);
for(ll i=1;i<=Size;i++)ARm.push_back({rand()%50+3,rand()%100+10});
tiaoxuanwuqi:
for(ll i=1;i<=Size;i++)printf("%lld.伤害%lld 耐久%lld\n",i,ARm[i].grade,ARm[i].durability);
cin>>num;
if(num>Size){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("跑路成功!牛逼!");
else
{
printf("敢跑路!!!\n");
if(timesfled)printf("还来,上次没打你是吧!!!\n");
ll probability=rand()%100;
if(probability<95||timesfled)printf("被肘击了,扣%lld点血。\n",(timesfled?100LL:rand()%80+10));
else printf("放你一马!\n");
timesfled=1;
}
break;
}
case 2:
{
ll grade=ARm[num].grade,durability=ARm[num].durability,money=grade*2+durability*3+rand()%100;
printf("给钱!%lld金币!\n",money);
printf("1.付钱\n");
printf("2.讲价\n");
ll num;
cin>>num;
switch (num)
{
case 1:
{
if(gold<money){printf("没钱还来买!!!滚!\n");return;}
gold-=money;
printf("花费了%lld点金币!\n",money);
cls();
printf("为自己的武器取个名字吧!");
str name;
cin>>name;
ARMS ARm(name,grade,durability,1);
arm.push_back(ARm);
}
break;
case 2:
break;
default:
printf("还想干嘛!\n");
break;
}
break;
}
default:
printf("还想干嘛!\n");
break;
}
}
void armsell()
{
for(ll i=0;i<arm.size();i++)
{
auto ar=arm[i].dataviewing();
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())printf("你哪来那么多武器!\n");
else if(num==0)printf("空手指你还卖,滚!\n");
else
{
auto ar=arm[num].dataviewing();
ll money=ar.grade*2+ar.durability*3-rand()%100;
printf("%lld金币,拿了赶紧走!\n",money);
gold+=money;
arm.erase(arm.begin()+num);
}
}
signed main()
{
srand(time(0));
gold=1000000000000;
armsshop();
return 0;
}
这代码为啥会CE啊!!!
(AI的回复:你的armsell()函数没有实现
)
全部评论 10
d'd'd'd'd'd'd'd'd'd'd'd'd'd'd'd'd'd'd
2025-10-04 来自 浙江
0再一次给自己评论
2025-10-05 来自 浙江
0
d'd'd'd'd'd'd'd'd'd'd'd'd'd'd'd'd'd'd
2025-10-04 来自 浙江
0顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶
2025-10-04 来自 浙江
0来给自己评论

2025-10-04 来自 浙江
0
2025-10-04 来自 重庆
0修好了!!!
2025-10-04 来自 浙江
0#include <windows.h>
#include <bits/stdc++.h>
#include <vector>
#include <cstdlib>
#include <ctime>
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 {
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 dataviewing() { ARM temp; temp.grade = this->grade; temp.durability = this->durability; temp.name = this->name; temp.f = this->f; return temp; } void attack(ENEMY& a); void ARMsell() { 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; }2025-10-04 来自 浙江
0ENEMy dataviewing() { ENEMy temp; temp.name = this->name; temp.hp = this->hp; temp.grade = this->grade; return temp; } void attack();};
void ARMS::attack(ENEMY& a) {
if(this->durability >= 1) {
ENEMy c = a.dataviewing();
a.hurt(this->grade);
this->durability--;
ENEMy b = a.dataviewing();
printf("使用%s对%s造成%lld点伤害\n%s还剩%lld点耐久\n%s还剩%lld点血\n",
this->name.c_str(), b.name.c_str(), min(this->grade, c.hp),
this->name.c_str(), this->durability, b.name.c_str(), b.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 endcheck(ENEMY a) {
if(player_die()) return 2;
if(a.die()) return 1;
return 0;
}vector<ARMS> arm;
void merchant();
void shelf();
void armsell();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:
break;
case 3:
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:
armsell();
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);
}2025-10-04 来自 浙江
0ll 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("跑路成功!牛逼!"); } else { printf("敢跑路!!!\n"); if(timesfled) printf("还来,上次没打你是吧!!!\n"); ll probability2 = rand() % 100; if(probability2 < 95 || timesfled) { ll damage = (timesfled ? 100LL : rand() % 80 + 10); printf("被肘击了,扣%lld点血。\n", damage); h = max(h - damage, 0LL); } else { printf("放你一马!\n"); } timesfled = 1; } break; } case 2: { ll grade = ARm[num - 1].grade, durability = ARm[num - 1].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)); break; } case 2: // 讲价功能待实现 break; default: printf("还想干嘛!\n"); break; } break;2025-10-04 来自 浙江
0
2025-10-03 来自 浙江
0我是merchant函数里调用armsell的部分报错
2025-10-03 来自 浙江
0自动编译:完全正确
F11:开:
2025-10-03 来自 浙江
0你把版本换成11试试?
2025-10-03 来自 浙江
0
不是你用window。h提交测评你说CE不CE
2025-10-03 来自 浙江
0我在本地编译的,Windows
2025-10-03 来自 浙江
0o?
2025-10-03 来自 浙江
0啥意思
2025-10-03 来自 浙江
0
d
2025-10-02 来自 浙江
0这是汇编(闲的没事):
https://www.acgo.cn/discuss/rest/586162025-10-02 来自 浙江
0

























有帮助,赞一个