搜索
查看: 534|回复: 3
打印 上一主题 下一主题

大佬帮看看哪里错了

[复制链接]
跳转到指定楼层
楼主
发表于 2018-1-30 12:55:07 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
5啊哈币


最佳答案

查看完整内容

#include #include #include int x=3,y=5; const int fx[4][2]={{-1,0},{1,0},{0,-1},{0,1}}; char a[50][50]={" ### ", " #*# ", "#####o######", "#* os o *#", "#######o####", " # # ", ...
沙发
发表于 2018-1-30 12:55:08 | 只看该作者
本帖最后由 Living Things. 于 2018-3-20 16:46 编辑
a580230a 发表于 2018-1-30 12:55
#include
#include
#include

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int x=3,y=5;
const int fx[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
char a[50][50]={"    ###     ",
                                "    #*#     ",
                                "#####o######",
                                "#*  os o  *#",
                                "#######o####",
                                "      # #   ",
                                "      #*#   ",
                                "      ###   "};
void move(int v)
{
        switch(a[x+fx[v][0]][y+fx[v][1]])
        {
                case 'o':
                        if(a[x+fx[v][0]*2][y+fx[v][1]*2]!='#')
                        {        
                                a[x][y]=' ';
                                a[x+=fx[v][0]][y+=fx[v][1]]='s';
                                a[x+fx[v][0]][y+fx[v][1]]='o';
                        }
                        break;
                case '#':
                        break;
                case ' ':
                        a[x][y]=' ';
                        a[x+=fx[v][0]][y+=fx[v][1]]='s';
                        break;
                default:
                        puts("Error");
                        getch();
                        exit(0);
        }
}
int main()
{
        int i;
        while(a[1][5]=='*' || a[3][1]=='*' || a[3][9]=='*' || a[6][7]=='*')
        {
            for(i=0;i<8;i++)
                        puts(a);
                switch(getch())
                {
                        case 'W':case 'w':case '\110':
                                move(0);
                                break;
                        case 'S':case 's':case '\120':
                                move(1);
                                break;
                        case 'A':case 'a':case '\113':
                                move(2);
                                break;
                        case 'D':case 'd':case '\115':
                                move(3);
                                break;
                }
                system("cls");
    }
    for(i=0;i<8;i++)
                puts(a);
    puts("你赢了!");
        system("pause > nul");
        return 0;
}
板凳
 楼主| 发表于 2018-1-30 12:55:34 | 只看该作者
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main()
{
        char a[50][50]={"    ###",
                                        "    #*#",
                    "#####o######",
                    "#*  os o  *#",
                    "#######o####",
                    "      # #",
                    "      #*#",
                    "      ###",
                    }
    int o,i,i1,x1,x2,x3,x4,x5,x6,x7;
    x1=1;x2=5;x3=3;x4=1;x5=10;x6=6;x7=7;i=1;i1=1;
    char m;
    for(i=0;i<=7;i++)
                pust(a[i]);
    while(a[x1][x5]!='o'||a[x3][x4]!='o'||a[x3][x5]!='o'||a[x6][x7]!='o')
        {
                        m=getch();
            if(m=='s')
            {
                                if(a[i+1][i1]!='#')
                                {
                                        a[i][i1]=' ';
                    i++;
                    a[i][i1]='s';
                    if(a[i][i1]=='o'||a[i+1][i1]!='#')
                                                {
                        a[i+1][i1]='o';  
                        }                     
                                        if(a[i][i1]=='o'||a[i+1][i1]=='#')  
                    {
                                                a[i-1][i1]='s';
                        a[i][i1]='o';
                    }  
                    pust(a[i]);                 
                        
                        
                }
            }
        }
   
        system("pause");
        return 0;
}

点评

天花乱坠……  发表于 2018-1-30 16:25
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

广播台
特别关注
快速回复 返回顶部 返回列表