zoukankan      html  css  js  c++  java
  • 09.17,二维数组,地图

      string[,] erwei = new string[10, 10] 
                {
                    { "","","","","","","","","",""}, 
                    { "","  ","  ","  ","  ","  ","","  ","  ",""}, 
                    { "","  ","","","","  ","","","  ",""},
                    { "","  ","","  ","","  ","  ","","  ",""},
                    { "","  ","","  ","","","  ","","  ",""},
                    { "","  ","","  ","  ","","","","  ",""},
                    { "","  ","","  ","  ","  ","  ","  ","  ",""},
                    { "","  ","  ","  ","","","","  ","",""},
                    { "","  ","","  ","  ","","  ","  ","  ",""},
                    { "","","","","","","","","","" } 
                };
    
                int reny = 4;
                int renx = 6;
                erwei[reny, renx] = "";
    
                while (true)
                {
                   
                    for (int j = 0; j < 10; j++)
                    {
                        for (int i = 0; i < 10; i++)
                        {
                            Console.Write(erwei[j, i]);
                        }
                        Console.Write("
    ");
                    }
    
                    erwei[reny, renx] = "  ";
                    Console.Write("请按wasd来运动:");
                    string caozuo = Console.ReadLine();
                    if (caozuo == "w")
                    {
                        if (erwei[reny - 1, renx] == "  ")
                        {
                            reny = reny - 1;
                        }
                    }
                    if (caozuo == "a")
                    {
                        if (erwei[reny, renx - 1] == "  ")
                        {
                            renx = renx - 1;
                        }
                    }
                    if (caozuo == "s")
                    {
                        if (erwei[reny + 1, renx] == "  ")
                        {
                            reny = reny + 1;
                        }
                    }
                    if (caozuo == "d")
                    {
                        if (erwei[reny, renx + 1] == "  ")
                        {
                            renx = renx + 1;
                        }
                    }
    
                    erwei[reny, renx] = "";
                    Console.Clear();
                }
                Console.ReadLine();
  • 相关阅读:
    待办
    安卓微信浏览器修改的代码总是不生效
    微信浏览器内核2
    微信浏览器内核
    随记
    三次握手最后一个ack没有收到怎么办?
    判断偶数:
    利用kubeadm工具安装Kubernetes1.15版本
    kubernetes安装Helm
    最大子列和(附加子列初始元素和末尾元素)
  • 原文地址:https://www.cnblogs.com/cf924823/p/4816380.html
Copyright © 2011-2022 走看看