| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1261 人关注过本帖
标题:有没有大佬看出来问题一直有两处错误
取消只看楼主 加入收藏
MRK
Rank: 1
等 级:新手上路
帖 子:4
专家分:4
注 册:2019-5-13
结帖率:0
收藏
已结贴  问题点数:20 回复次数:0 
有没有大佬看出来问题一直有两处错误
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
void ditu()
{
    char a[30][30]={"   ###",
                    "   #*#",
                    "   # #",
                    "####0######",
                    "#* 0 r 0 *#",
                    "##### #####",
                    "    #0#",
                    "    #*#",
                    "    ###"    };
        int i,x,y;
        x=4;
        y=5;
        char ch;
        for(i=0;i<9;i++)
        {
            puts(a[i]);
        }
}
void HEL()
{
        ch=getch();
        if(ch=='s')
        {
            if(a[x+1][y]!='#')//下面是否为墙
            {
                if(a[x+1][y]!='0')//下面是否为箱子
                {
                    if(a[x+1][y]!='@')
                    {
                        a[x][y]=' ';//下面不为墙或者箱子时运行
                        x++;
                        a[x][y]='r';
                    }
                }
                else if(a[x+2][y]!='#')//若下面为箱子则运行以下内容
                {
                    if(a[x+3][y]!='*')
                    {
                        a[x][y]=' ';
                        x++;
                        a[x][y]='r';
                        x++;
                        a[x][y]='@';
                        x--;
                    }
                    else if(a[x+3][y]!='#')
                    {
                        a[x][y]=' ';
                        x++;
                        a[x][y]='r';
                        x++;
                        a[x][y]='0';
                        x--;
                    }
                }   
            }
        }
        if(ch=='w')
        {
            if(a[x-1][y]!='#')//上面是否为墙
            {
                if(a[x-1][y]!='0')//上面是否为箱子
                {
                    if(a[x-1][y]!='@')
                    {
                        a[x][y]=' ';//上面不为墙或者箱子时运行
                        x--;
                        a[x][y]='r';
                    }
                }
                else if(a[x-2][y]!='#')//若上面为箱子则运行以下内容
                {
                    if(a[x-3][y]!='*')
                    {
                        a[x][y]=' ';
                        x--;
                        a[x][y]='r';
                        x--;
                        a[x][y]='@';
                        x++;
                        
                    }
                    else if(a[x-3][y]!='#')
                    {
                        a[x][y]=' ';
                        x--;
                        a[x][y]='r';
                        x--;
                        a[x][y]='0';
                        x++;
                    }
                }   
            }
        }
        if(ch=='a')
        {
            if(a[x][y-1]!='#')//左边是否为墙
            {
                if(a[x][y-1]!='0')//左边是否为箱子
                {
                    if(a[x][y-1]!='@')
                    {
                        a[x][y]=' ';//左边不为墙或者箱子时运行
                        y--;
                        a[x][y]='r';
                    }
                }
                else if(a[x][y-2]!='#')//若左边为箱子则运行以下内容
                {
                    if(a[x][y-3]!='*')
                    {
                        a[x][y]=' ';
                        y--;
                        a[x][y]='r';
                        y--;
                        a[x][y]='@';
                        y++;
                        
                    }
                    else if(a[x][y-3]!='#')
                    {
                        a[x][y]=' ';
                        y--;
                        a[x][y]='r';
                        y--;
                        a[x][y]='0';
                        y++;
                    }
                }   
            }
        }
        if(ch=='d')
        {
            if(a[x][y+1]!='#')//右边是否为墙
            {
                if(a[x][y+1]!='0')//右边是否为箱子
                {
                    if(a[x][y+1]!='@')
                    {
                        a[x][y]=' ';//右边不为墙或者箱子时运行
                        y++;
                        a[x][y]='r';
                    }
                }
                else if(a[x][y+2]!='#')//若右边为箱子则运行以下内容
                {
                    if(a[x][y+3]!='*')
                    {
                        a[x][y]=' ';
                        y++;
                        a[x][y]='r';
                        y++;
                        a[x][y]='@';
                        y--;
                    }
                    else if(a[x][y+3]!='#')
                    {
                        a[x][y]=' ';
                        y++;
                        a[x][y]='r';
                        y++;
                        a[x][y]='0';
                        y--;
                    }
                }   
            }
        }
}
int main()
{
    ditu();
    while(1)
    {
        HEL;
    }
    return 0;
}





搜索更多相关主题的帖子: 错误 内容 是否为 include 运行 
2020-04-23 09:43
快速回复:有没有大佬看出来问题一直有两处错误
数据加载中...
 
   



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

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