使用c# 根据给出的一个点位置行列间距生成其他的点
您可以使用C#的循环结构来生成其他的点。以下是一个示例代码:
using System;
class Program
{
static void Main()
{
// 给出的点的位置
int startX = 0;
int startY = 0;
// 行和列数
int rows = 3;
int columns = 3;
// 间距
int spacing = 10;
// 生成其他的点
for (int row = 0; row < rows; row++)
{
for (int column = 0; column < columns; column++)
{
// 计算新点的位置
int newX = startX + column * spacing;
int newY = startY + row * spacing;
// 输出新点的位置
Console.WriteLine("Point ({0}, {1})", newX, newY);
}
}
// 等待用户输入
Console.ReadLine();
}
}
上述代码会输出以下结果:
Point (0, 0)
Point (10, 0)
Point (20, 0)
Point (0, 10)
Point (10, 10)
Point (20, 10)
Point (0, 20)
Point (10, 20)
Point (20, 20)
请根据您的具体需求调整起始点、行数、列数和间距的数值
原文地址: http://www.cveoy.top/t/topic/h5l2 著作权归作者所有。请勿转载和采集!