| 网站首页 | 业界新闻 | 群组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 编程论坛
共有 374 人关注过本帖
标题:萌新,求大佬帮助
只看楼主 加入收藏
yd2457606614
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2018-8-3
结帖率:100%
  已结贴   问题点数:20  回复次数:4   
萌新,求大佬帮助
#include<iostream>
#include<Windows.h>
#include<conio.h>
#include<cstdio>
//控制台的输入输出; //mspaind在cmd中打开画图。
using namespace std;
int mmap[8][10]={(0,0,0,1,1,1,0,0,0,0),
                (0,0,0,1,3,1,0,0,0,0),
                (0,0,0,1,0,1,1,1,1,0),
                (0,1,1,1,4,0,4,3,1,0),
                (0,1,3,0,4,5,1,1,1,0),
                (0,1,1,1,1,4,1,0,0,0),
                (0,0,0,0,1,3,1,0,0,0),
                (0,0,0,0,1,1,1,0,0,0)};
void Draw_Map(){
    for (int i = 0; i < 8; i++){
        for(int j = 0; j < 10;j++){
            switch(mmap[i][j]){
            case 0:cout<<" ";break;
            case 1:cout<<"#";break;
            case 3:cout<<"*";break;
            case 4:cout<<"$";break;
            case 5:cout<<"a";break;}
        
        }
    }
};

void PlayGame(){
    int x,y;
    for(int i = 0;i < 8; i++){
        for(int j = 0; j < 10;j++){
            if(mmap[i][j] == 5){
                x = i;
                y = j;
            }
        }
    }
    char ch;
    ch =getch();
    switch(ch){
        case 'W':
        case 'w':if(mmap[x - 1][y] == 0){
                    mmap[x - 1][y] = 5;
                    mmap[x][y] = 0;
        }else if (mmap[x-1][y]==4){
            if (mmap[x -2][y] ==0||mmap[x - 2][y] == 3){
                mmap[x - 2][y] = 4;
                mmap[x -1][y] = 5;
                mmap[x][y]=0;
            }
        }
        break;
    case 'S':
    case 's':if(mmap[x + 1][y] == 0){
                    mmap[x + 1][y] = 5;
                    mmap[x][y] = 0;
        }else if (mmap[x+1][y]==4){
            if (mmap[x + 2][y] ==0||mmap[x + 2][y] == 3){
                mmap[x + 2][y] = 4;
                mmap[x + 1][y] = 5;
                mmap[x][y]=0;
            }
        }
        break;
        case 'A':
        case 'a':if(mmap[x][y-1] == 0){
                    mmap[x][y-1] = 5;
                    mmap[x][y] = 0;
        }else if (mmap[x][y-1]==4){
            if (mmap[x][y-2] ==0||mmap[x][y-2] == 3){
                mmap[x][y-2] = 4;
                mmap[x][y-1] = 5;
                mmap[x][y]=0;
            }
        }
        break;
    case 'D':
    case 'd':if(mmap[x][y+1] == 0){
                    mmap[x][y+1] = 5;
                    mmap[x][y] = 0;
        }else if (mmap[x][y+1]==4){
            if (mmap[x][y+2] ==0||mmap[x][y+2] == 3){
                mmap[x][y+2] = 4;
                mmap[x][y+1] = 5;
                mmap[x][y]=0;
            }
        }
        break;
    }
}
int main(){
   
    mciSendString("open ",0,0,0);//打开音频
    mciSendString("play",0,0,0);
    while (1){
        Draw_Map();
        PlayGame();
    }
    return 0;
}
[Error] ld returned 1 exit status

[此贴子已经被作者于2018-8-3 22:20编辑过]

2018-08-03 22:17
吹水佬
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:169
帖 子:6385
专家分:27952
注 册:2014-5-20
  得分:0 
是不是程序在运行


[此贴子已经被作者于2018-8-4 05:12编辑过]

2018-08-04 05:11
自学的数学
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:17
帖 子:603
专家分:2418
注 册:2017-11-15
  得分:20 
C:\Users\ADMINI~1\AppData\Local\Temp\ccAF2pX4.o    测试点.cpp:(.text+0x60c): undefined reference to `mciSendStringA@16'
C:\Users\ADMINI~1\AppData\Local\Temp\ccAF2pX4.o    测试点.cpp:(.text+0x633): undefined reference to `mciSendStringA@16'
d:\program files\dev-c++\32位\mingw32\mingw32\bin\ld.exe    C:\Users\ADMINI~1\AppData\Local\Temp\ccAF2pX4.o: bad reloc address 0xc in section `.rdata'
d:\program files\dev-c++\32位\mingw32\mingw32\bin\ld.exe    final link failed: Invalid operation
2018-08-04 09:54
yd2457606614
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2018-8-3
  得分:0 
回复 3楼 自学的数学
可以指出错的地方吗
2018-08-04 16:17
自学的数学
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:17
帖 子:603
专家分:2418
注 册:2017-11-15
  得分:0 
[Error] ld returned 1 exit status:
编译的过程中出现这个错误极有可能是因为函数名错误引起的,因此回到源码中观察函数名,尤其是那些库函数中的函数。
2018-08-04 20:03







关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023927 second(s), 8 queries.
Copyright©2004-2018, BCCN.NET, All Rights Reserved