如何着色表的一部分

时间:2015-08-18 15:09:27

标签: c# linq

我得到了这个显示乘法表的代码,我应该制作一个彩色方块的对角线,但我肯定不知道如何。有谁可以帮助我?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Task1
{
    class Program
    {
        static void tab(byte b)
        {
            Console.WriteLine("It's {0} x {0}\n", b);
            // Rows
            for (int i = 1; i <= 10; i++)
            {
                // Columns
                for (int j = 1; j <= b; j++)
                Console.Write("{0}\t", j * i);
                Console.WriteLine();
            }
            Console.WriteLine();
        }
        static void Main(string[] args)
        {
            tab(10);
        }
    }
}

1 个答案:

答案 0 :(得分:1)

如果它真的是<html> <head> <script type="text/javascript"> function displayImage() { var j=parseInt({{payload}}); document.getElementById("img").src = images[j]; } function startTimer() { setInterval(displayImage,3000); } var images = []; images[0] = "image1.jpg"; images[1] = "image2.jpg"; images[2] = "image3.jpg"; </script> </head> <body onload="startTimer()"> <img id="img" src="image1.jpg"/> </body> </html>,那么你的行循环应该是b x b而不是10。

就目前的问题而言,您的分词发生在<= b时,因此这是您需要着色的条件。

如果您需要帮助着色,请使用i == j成员进行设置。当你用彩色盒子做完时,不要忘记改回来。