| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3989 人关注过本帖
标题:新手求教,输出一个9*9的数组
只看楼主 加入收藏
番茄暴走123
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2016-3-3
结帖率:0
收藏
已结贴  问题点数:20 回复次数:16 
新手求教,输出一个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
vxman
Rank: 1
等 级:新手上路
帖 子:1
专家分:7
注 册:2016-3-8
收藏
得分:7 
因为你有 Console.ReadLine();这一行代码,所以每输出一行需要打一下回车,把这个删除就好了
2016-03-08 19:54
番茄暴走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
over1230
Rank: 8Rank: 8
等 级:贵宾
威 望:25
帖 子:113
专家分:897
注 册:2009-10-9
收藏
得分:7 
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.WriteLine();
            }
            Console.ReadLine();
2016-03-10 11:31
番茄暴走123
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2016-3-3
收藏
得分:0 
谢谢
2016-03-10 15:33
ggj2016
Rank: 1
等 级:新手上路
帖 子:1
专家分:7
注 册:2016-3-11
收藏
得分:7 
学习 了
2016-03-11 15:02
番茄暴走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
qq1023569223
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:湖南科技大学
等 级:贵宾
威 望:26
帖 子:2753
专家分:13404
注 册:2010-12-22
收藏
得分:0 
你这个程序要实现什么,感觉一点用都没有,错误一大堆,建议再学习吧。参考下下面的看看。
程序代码:
class Program
{    
    public void GeneratePointMatrix( )
    {
        int k=0;
        for(int i=0;i<9;i++)
        {
            for(int j=0;j<9;j++)
            {
                k=i*j;
                Console.Write(k.ToString()+"  ");
            }
            Console.WriteLine();
        }
    }  
       
    static void Main(string[] args)
    {
        GeneratePointMatrix();
        
        Console.ReadKey();
    }
}


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


   唯实惟新 至诚致志
2016-03-21 10:43
番茄暴走123
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2016-3-3
收藏
得分:0 
回复 9楼 qq1023569223
谢谢版主,就是想输出一个9×9数组,赋值都是"."。
2016-03-21 11:00
快速回复:新手求教,输出一个9*9的数组
数据加载中...
 
   



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

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