| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1911 人关注过本帖
标题:刚学C#,不懂正方形输出循环问题,大家帮帮迷途的我啦~~deng
取消只看楼主 加入收藏
xiayulexiayu
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2009-10-10
结帖率:0
收藏
已结贴  问题点数:10 回复次数:3 
刚学C#,不懂正方形输出循环问题,大家帮帮迷途的我啦~~deng
using System;
using System.Collections.Generic;
using System.Text;

namespace ZUOYE2
{
    class Program
    {
        static void Main()
        {
        tuxingchose:
            Console.WriteLine("请选择要输出的图形 1.正方形 2.长方形 3.三角形");
            string tuxing = Console.ReadLine();
            if (tuxing != "1" && tuxing != "2" && tuxing != "3")
            {
                Console.WriteLine("输入错误!");
                goto tuxingchose;
            }
            if (tuxing == "1")
            {
                Console.WriteLine("请输入正方形的边长");
         
            int a = Int32.Parse(Console.ReadLine());
                if (a <= 0)
                {
                    Console.WriteLine("输入错误!");
               
                }
            kongshixin1:
                Console.Write("是否实心?按键Y或y为实心,N或n为空心:");
                string b = Console.ReadLine();//b为是否为实心
                if (b != "y" && b != "Y" && b != "n" && b != "N")
                {
                    Console.WriteLine("输入错误!");
                    goto kongshixin1;

                }
                Console.Write("选择什么符号表示(回车则为*):");
                string c = Console.ReadLine();//c为图形的符号表示

                if (c == "")
                    c = "*";

                for (int i = 0; i < a; i++)----->正方形不是四条边吗?
                {
                    for (int j = 0; j < a; j++)---->怎么只得i和j?输出怎样不是2条边而是四条边?究竟是怎样输出的?搞不懂
                    {
                        if (b == "Y" || b == "y")
                            Console.Write(" " + c);
                        if (b == "N" || b == "n")
                        {
                            if (i == 0 || i == a - 1 || j == 0 || j == a - 1)
                                Console.Write(" " + c);
                            else
                                Console.Write("  ");
                        }
                    }
                    Console.WriteLine();//正方形完毕

                  


                }
            }
        }
    }
}

大家帮下忙喇,小弟实菜~~~
搜索更多相关主题的帖子: 输出 deng 迷途 正方形 
2009-10-11 00:12
xiayulexiayu
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2009-10-10
收藏
得分:0 
????人呢?
2009-10-11 00:22
xiayulexiayu
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2009-10-10
收藏
得分:0 
?????没人会?????来人啊,在线等~~凄凉啊~~~~
2009-10-11 00:27
xiayulexiayu
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2009-10-10
收藏
得分:0 
来人啊
2009-10-11 00:35
快速回复:刚学C#,不懂正方形输出循环问题,大家帮帮迷途的我啦~~deng
数据加载中...
 
   



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

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