减少每行的符号数 [英] reducing number of symbols per row

查看:98
本文介绍了减少每行的符号数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我如何每行打印给定数量的符号,然后每行少打印一个符号,直到没有剩余?

问题:我可以将"Console.Write(#");-链接到x或Y的值吗?

像这张照片一样: http://csharpskolan.se/image.php?id=115 [ ^ ]

我的代码当前是:

Alright, how do i print a given number of a symbol per row, and then one less each row untill there is none left?

Question: Can i link "Console.Write("#"); - to the value of x or Y?

like this picture: http://csharpskolan.se/image.php?id=115[^]

My code is currently:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Oh Herro!");
            for (int y = 10; y >= 1; y--)
            {
                for (int x = 10; x >= 0; x--)
                {
                    Console.Write("#");
                }
             Console.WriteLine();
            }
        }
    }
}

推荐答案

我知道这是家庭作业,但是我们很少有机会使用代码进行实际回答.这是一种实现方法:

I know it''s homework, but we get so few opportunities to actually answer with code. Here''s one way to do it:

string pounds = "##########";

Console.WriteLine("Oh Herro!");
for(int i = 0; i < pounds.length; i++)
{
    Console.WriteLine(pounds.SubString(i));
}
Console.WriteLine();


尝试一下:)

try this :)

static void Main(string[] args)
        {

            for (int y = 1; y <= 10; y++)
            {
                for (int x = 10; x >= y-1; x--)
                {
                    Console.Write("#");
                }
                Console.WriteLine();

            }
            Console.WriteLine("Oh Herro!");
            Console.ReadLine();

        }


这篇关于减少每行的符号数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆