C++编译错误
我设计了一个程序,原来编译的好好的,后来加了个段代码,觉得不合适删了之后就编译错误了,错误信息:
[Error] ld returned 1 exit status
这是源代码,/* 后为加上内容
#include<iostream>
#include<stdlib.h>
#include<unistd.h>
#include<cstdio>
#include<cmath>
using namespace std;
double player_healthy=20;//定义玩家属性
int player_attack=2;
int player_denfense=0;
int player_tougness=0;
int player_rank=0;
int player_level=0;
char F3[17][67];//用来生成战场
char key;//用来存储行为
int x=2,y=2;//定义玩家坐标
void space()//将战场填充满空格
{
for(int i=1;i<=17;i++)
{
for(int j=1;j<=67;j++)
{
F3[i][j]=' ';
}
}
return ;
}
void place1()//定义一号战场
{
for(int i=1;i<=67;i++)
{
F3[1][i]='-';
F3[17][i]='-';
}
for(int j=2;j<=17;j++)
{
F3[j][1]='|';
F3[j][67]='|';
}
return ;
}
void place2()//定义二号战场
{
for(int i=1;i<=67;i++)
{
F3[1][i]='-';
F3[17][i]='-';
}
for(int j=2;j<=17;j++)
{
F3[j][1]='|';
F3[j][67]='|';
}
for(int n=21;n<=47;n++)
{
F3[6][n]='-';
F3[12][n]='-';
}
for(int m=7;m<=11;m++)
{
F3[m][21]='|';
F3[m][47]='|';
}
F3[6][34]=' ';
F3[12][34]=' ';
F3[9][21]=' ';
F3[9][47]=' ';
return ;
}
void good_things()//定义随机奖励
{
int F3_i;
int F3_j;
static int x1=F3_i,y1=F3_j;
F3_i=rand()%27+1;
F3_j=rand()%37+1;
int thing=rand()%3+1;
if(thing==1)
{
F3[F3_i][F3_j]='H';
}
else
{
thing-=1;
F3[F3_i][F3_j]=(thing==2)?'A':'D';
}
return ;
}
void sword1()//定义剑士
{
int F3_i;
int F3_j;
static int x2=F3_i,y2=F3_j;
F3_i=rand()%27+1;
F3_j=rand()%37+1;
F3[F3_i][F3_j]='a';
return ;
}
void sword2()
{
int F3_i;
int F3_j;
static int x3=F3_i,y3=F3_j;
F3_i=rand()%25+1;
F3_j=rand()%35+1;
static double sword2_healthy=rand()%9+12;
static int sword2_attack=rand()%6+1;
static int sword2_denfense=rand()%8;
static int sword2_tougness=rand()%5;
static int sword2_rank=rand()%11+13;
F3[F3_i][F3_j]='b';
return ;
}
void sword3()
{
int F3_i;
int F3_j;
static int x4=F3_i,y4=F3_j;
F3_i=rand()%20+1;
F3_j=rand()%30+1;
static double sword3_healthy=rand()%12+12;
static int sword3_attack=rand()%6+3;
static int sword3_denfense=rand()%12;
static int sword3_tougness=rand()%6+1;
static int sword3_rank=rand()%21+17;
F3[F3_i][F3_j]='c';
return ;
}
void bow()//定义弓箭手
{
int F3_i;
int F3_j;
static int x5=F3_i,y5=F3_j;
F3_i=rand()%17+1;
F3_j=rand()%27+1;
static double bow_healthy=rand()%15+10;
static int bow_attack=rand()%6+4;
static int bow_denfense=rand()%15;
static int bow_tougness=rand()%7+2;
static int bow_rank=rand()%36+23;
F3[F3_i][F3_j]='a';
return ;
}
void player()//定义玩家坐标
{
F3[x][y]='@';
return ;
}
void output()//用来输出战场
{
/*srand(0);
int places=rand()%2;//用来随机分布战场,有趣的是,二战场怪物可能暂时占据墙壁的位置
space();
loop:
cout<<places<<endl;
sleep(5);
//*注:loop为我测试rand时的临时代码
(places==0)? place1():place2();
system("cls");//清屏
for(int i=1;i<=17;i++)
{
for(int j=1;j<=67;j++)
{
cout<<F3[i][j];
}
cout<<endl;
}
return;
}
int main()
{
player();
output();
cin>>key;
int perhaps=rand()%10;//用来随机选择行为方,玩家70%,敌人30%
perhaps=(perhaps<=6)?0:1;
switch(key)
{
case 119:if(y-1!=' ')//向上移动
{
player_healthy+=0.5;
}
else
{
F3[x][y]=' ';
y-=1;
F3[x][y]='@';
}
break;
case 97:break;
case 115:break;
case 100:x=1;
}
}
求大神朋友指点怎么修改,再给一点建议
补充:编译器:TDM-GCC 4.9.2 32-bit Release版本:Dev-Cpp.5.11最佳答案
程序没有问题
你ld出错的话,看下系统进程,是否你的程序正在运行
当然,重新启动电脑后肯定是可以编译程序的
追问:
是的,可以了
其他回答
暂无其它回答!