| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3979 人关注过本帖
标题:新手求教,输出一个9*9的数组
取消只看楼主 加入收藏
番茄暴走123
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2016-3-3
结帖率:0
收藏
已结贴  问题点数:20 回复次数:8 
新手求教,输出一个9*9的数组
static void Main(string[] args)
        {
            string[,] array = new string[9, 9];
            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    array[i, j] = ".";
                    Console.Write(array[i, j]);
                }
                Console.ReadLine();

            }

请教,输出的9*9数组,只显示了一行,必须手动打个回车才能输出下一行。百度了一下,\r\n可以用,可是改成 Console.ReadLine("\r\n"),程序总出错,为啥子呢
搜索更多相关主题的帖子: 百度 
2016-03-08 17:11
番茄暴走123
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2016-3-3
收藏
得分:0 
还是不对呢,怎模办
 static void Main(string[] args)
        {
            string[,] array = new string[9, 9];
            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    array[i, j] = ".";
                    Console.Write(array[i, j]);
                }
                Console.Write('\n');      
            }
                        // this is for get input, which will stop the screen
        }
2016-03-10 10:58
番茄暴走123
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2016-3-3
收藏
得分:0 
谢谢
2016-03-10 15:33
番茄暴走123
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2016-3-3
收藏
得分:0 
继续求教,这个数组如果用函数的方式写的话,怎么写呢
2016-03-21 09:54
番茄暴走123
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2016-3-3
收藏
得分:0 
class Program
    {
        public void GeneratePointMatrix(int x, int y,string Value)
        {
            for (int i=0;i<9;i++)
            {
                for (int j=0;j<9;j++)
                {
                    int x=int.Parse(Value);
                    int y=int.Parse(Value);
                }
            }
        }  
       static void Main(string[],args)
       {
           GeneratePointMatrix();
           String Value=".";
           Console.WriteLine();
           Console.ReadLine();
       }
    }

Error    5    The type or namespace name 'args' could not be found (are you missing a using directive or an assembly reference?)    C:\Users\zhanglei\Documents\Visual Studio 2010\Projects\ConsoleApplication13\ConsoleApplication13\Program.cs    21    34    ConsoleApplication13
Error    6    No overload for method 'GeneratePointMatrix' takes 0 arguments    C:\Users\zhanglei\Documents\Visual Studio 2010\Projects\ConsoleApplication13\ConsoleApplication13\Program.cs    23    12    ConsoleApplication13
Error    1    Identifier expected    C:\Users\zhanglei\Documents\Visual Studio 2010\Projects\ConsoleApplication13\ConsoleApplication13\Program.cs    21    33    ConsoleApplication13
Error    2    Identifier expected    C:\Users\zhanglei\Documents\Visual Studio 2010\Projects\ConsoleApplication13\ConsoleApplication13\Program.cs    21    38    ConsoleApplication13
Error    4    A local variable named 'y' cannot be declared in this scope because it would give a different meaning to 'y', which is already used in a 'parent or current' scope to denote something else    C:\Users\zhanglei\Documents\Visual Studio 2010\Projects\ConsoleApplication13\ConsoleApplication13\Program.cs    17    25    ConsoleApplication13
Error    3    A local variable named 'x' cannot be declared in this scope because it would give a different meaning to 'x', which is already used in a 'parent or current' scope to denote something else    C:\Users\zhanglei\Documents\Visual Studio 2010\Projects\ConsoleApplication13\ConsoleApplication13\Program.cs    16    25    ConsoleApplication13
2016-03-21 10:38
番茄暴走123
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2016-3-3
收藏
得分:0 
回复 9楼 qq1023569223
谢谢版主,就是想输出一个9×9数组,赋值都是"."。
2016-03-21 11:00
番茄暴走123
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2016-3-3
收藏
得分:0 
回复 9楼 qq1023569223
        public string Value;
        public void GeneratePointMatrix(int x, int y)
        {
            for (int i=0;i<9;i++)
            {
                for (int j=0;j<9;j++)
                {
                    int x=int.Parse(Value);
                    int y=int.Parse(Value);
                    String Value=".";
                }
            }
        }  
       static void Main(string[],args)
       {
           int i=9,int j=9;
           GeneratePointMatrix();
           Console.WriteLine();
           Console.ReadLine();
        }

Error    3    Identifier expected; 'int' is a keyword    C:\Users\zhanglei\Documents\Visual Studio 2010\Projects\ConsoleApplication13\ConsoleApplication13\Program.cs    25    20    ConsoleApplication13
Error    1    Identifier expected    C:\Users\zhanglei\Documents\Visual Studio 2010\Projects\ConsoleApplication13\ConsoleApplication13\Program.cs    23    33    ConsoleApplication13
Error    2    Identifier expected    C:\Users\zhanglei\Documents\Visual Studio 2010\Projects\ConsoleApplication13\ConsoleApplication13\Program.cs    23    38    ConsoleApplication13
还是有3个错误,怎么弄呢

      

[此贴子已经被作者于2016-3-21 11:12编辑过]

2016-03-21 11:05
番茄暴走123
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2016-3-3
收藏
得分:0 
回复 13楼 qq1023569223
是的,确实不懂,谢谢您的指教。可是,我用您的代码输进去后,怎么还是出现两个错误呢?
Error    1    Identifier expected    C:\Users\zhanglei\Documents\Visual Studio 2010\Projects\ConsoleApplication13\ConsoleApplication13\Program.cs    22    33    ConsoleApplication13
Error    2    Identifier expected    C:\Users\zhanglei\Documents\Visual Studio 2010\Projects\ConsoleApplication13\ConsoleApplication13\Program.cs    22    38    ConsoleApplication13
2016-03-21 14:34
番茄暴走123
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2016-3-3
收藏
得分:0 
回复 15楼 lantianke
谢谢亲
2016-03-28 16:11
快速回复:新手求教,输出一个9*9的数组
数据加载中...
 
   



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

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