标题:才学C# 帮哈忙。。。
只看楼主
using110
Rank: 1
来 自:成都
等 级:新手上路
帖 子:7
专家分:0
注 册:2011-4-7
结帖率:0
已结贴  问题点数:20 回复次数:7 
才学C# 帮哈忙。。。
请帮忙下。。怎么实现 用户输入数字在屏幕上用'#'打印   比如
 ###      ###   
#   #    #   #
#   #    #   #
#   #    #   #
 ###      
#   #    #   #
#   #    #   #
#   #    #   #
 ###      ###
   谢谢啊!!!
搜索更多相关主题的帖子: 用户 
2011-04-07 21:42
qq1023569223
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:湖南科技大学
等 级:贵宾
威 望:26
帖 子:2753
专家分:13404
注 册:2010-12-22
得分:4 
判断输入的字符是不是数字,不是输出一个空格,是的话输出一个'#"。

   唯实惟新 至诚致志
2011-04-07 22:29
海之舟
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:43
专家分:150
注 册:2011-1-8
得分:4 
看起来有点长,其实算法很简单,我也期望有高手能写出更简洁的代码:
 static void Main(string[] args)
        {
            int[,] arr0 ={
              {0,1,1,1,0},{1,0,0,0,1},{1,0,0,0,1},{1,0,0,0,1},{0,0,0,0,0},{1,0,0,0,1},{1,0,0,0,1},{1,0,0,0,1},{0,1,1,1,0}
                        };
            int[,] arr1 ={
              {0,0,0,0,0},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,0},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,0}
                        };
            int[,] arr2 ={
               {0,1,1,1,0},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,1},{0,1,1,1,0},{1,0,0,0,0},{1,0,0,0,0},{1,0,0,0,0},{0,1,1,1,0}
                        };
            int[,] arr3 ={
               {0,1,1,1,0},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,1},{0,1,1,1,0},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,1},{0,1,1,1,0}
                        };
            int[,] arr4 ={
               {0,0,0,0,0},{1,0,0,0,1},{1,0,0,0,1},{1,0,0,0,1},{0,1,1,1,0},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,0}
                        };
            int[,] arr5 ={
               {0,1,1,1,0},{1,0,0,0,0},{1,0,0,0,0},{1,0,0,0,0},{0,1,1,1,0},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,1},{0,1,1,1,0}
                        };
            int[,] arr6 ={
               {0,1,1,1,0},{1,0,0,0,0},{1,0,0,0,0},{1,0,0,0,0},{0,1,1,1,0},{1,0,0,0,1},{1,0,0,0,1},{1,0,0,0,1},{0,1,1,1,0}
                        };
            int[,] arr7 ={
               {0,1,1,1,0},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,0},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,0}
                        };
            int[,] arr8 ={
               {0,1,1,1,0},{1,0,0,0,1},{1,0,0,0,1},{1,0,0,0,1},{0,1,1,1,0},{1,0,0,0,1},{1,0,0,0,1},{1,0,0,0,1},{0,1,1,1,0}
                        };
            int[,] arr9 ={
              {0,1,1,1,0},{1,0,0,0,1},{1,0,0,0,1},{1,0,0,0,1},{0,1,1,1,0},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,1},{0,1,1,1,0}
                        };
           string value= Console.ReadLine();
           for (int m=0; m < 9;m++ )
           {
               for (int i =0; i < value.Length; i++)
               {
                   switch (value[i])
                   {
                       case '0':
                           for (int k = 0; k < 5; k++)
                           {
                               if (arr0[m,k] == 1)
                                   Console.Write("#");
                               else
                                   Console.Write(" ");
                           }
                           Console.Write("\t");
                           break;
                       case '1':
                           for (int k = 0; k < 5; k++)
                           {
                               if (arr1[m,k] == 1)
                                   Console.Write("#");
                               else
                                   Console.Write(" ");
                           }
                           Console.Write("\t");
                           break;
                       case '2':
                           for (int k = 0; k < 5; k++)
                           {
                               if (arr2[m,k] == 1)
                                   Console.Write("#");
                               else
                                   Console.Write(" ");
                           }
                           Console.Write("\t");
                           break;
                       case '3':
                           for (int k = 0; k < 5; k++)
                           {
                               if (arr3[m,k] == 1)
                                   Console.Write("#");
                               else
                                   Console.Write(" ");
                           }
                           Console.Write("\t");
                           break;
                       case '4':
                           for (int k = 0; k < 5; k++)
                           {
                               if (arr4[m,k] == 1)
                                   Console.Write("#");
                               else
                                   Console.Write(" ");
                           }
                           Console.Write("\t");
                           break;
                       case '5':
                           for (int k = 0; k < 5; k++)
                           {
                               if (arr5[m,k] == 1)
                                   Console.Write("#");
                               else
                                   Console.Write(" ");
                           }
                           Console.Write("\t");
                           break;
                       case '6':
                           for (int k = 0; k < 5; k++)
                           {
                               if (arr6[m,k] == 1)
                                   Console.Write("#");
                               else
                                   Console.Write(" ");
                           }
                           Console.Write("\t");
                           break;
                       case '7':
                           for (int k = 0; k < 5; k++)
                           {
                               if (arr7[m,k] == 1)
                                   Console.Write("#");
                               else
                                   Console.Write(" ");
                           }
                           Console.Write("\t");
                           break;
                       case '8':
                           for (int k = 0; k < 5; k++)
                           {
                               if (arr8[m,k] == 1)
                                   Console.Write("#");
                               else
                                   Console.Write(" ");
                           }
                           Console.Write("\t");
                           break;
                       case '9':
                           for (int k = 0; k < 5; k++)
                           {
                               if (arr9[m,k] == 1)
                                   Console.Write("#");
                               else
                                   Console.Write(" ");
                           }
                           Console.Write("\t");
                           break;
                   }
               }
               Console.Write("\r\n");
           }
}
2011-04-07 23:45
athenalux
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:河北石家庄
等 级:小飞侠
威 望:8
帖 子:975
专家分:2514
注 册:2008-11-26
得分:4 
楼上的很认真!

QQ:81704464
2011-04-08 08:42
using110
Rank: 1
来 自:成都
等 级:新手上路
帖 子:7
专家分:0
注 册:2011-4-7
得分:0 
很感谢!!!!!
2011-04-08 12:58
using110
Rank: 1
来 自:成都
等 级:新手上路
帖 子:7
专家分:0
注 册:2011-4-7
得分:0 
很感谢!!!!!
2011-04-08 12:58
OneHunter
Rank: 2
等 级:论坛游民
帖 子:25
专家分:26
注 册:2010-10-28
得分:4 
楼上厉害,不过我基础差一些,没看懂
比如,string value= Console.ReadLine();
这是一个字符串的声明和赋值,可是下边 使用了  value[i]  这个我就不理解了,如果是String类的话(今天刚学习),书上倒是说可以了(不过我很纠结),但是这个我就无语了,一个字符串可以当作数组用么? 求教~!

我还好~!
2011-04-08 15:14
zkmhywgsym
Rank: 2
等 级:论坛游民
帖 子:38
专家分:98
注 册:2011-3-5
得分:4 
好像string也是特殊的数组吧。。。记不清了。不过,3楼确实有够认真的
2011-04-08 15:53



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-335919-1-1.html




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

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