在C#中如何定义坐标数组,怎样赋值?又如何使用?
比如for(inti=0;i<18;i++){x1=x+Convert.ToInt32(d*Math.Cos(3.14*i/9));y1=y+Convert.ToInt3...
比如 for (int i = 0; i <18; i++)
{
x1 = x + Convert.ToInt32(d * Math.Cos(3.14*i/9));
y1 = y + Convert.ToInt32(d * Math.Sin(3.14*i/9));
Point []a = {new Point(x1,y1)};
}意思是把x1,y1的坐标放到坐标数组中来,这样对不对?如果对,那是怎么样访问这个数组呢?如果不对,那又是怎么样呢?求指导~~~!!!~~~ 展开
{
x1 = x + Convert.ToInt32(d * Math.Cos(3.14*i/9));
y1 = y + Convert.ToInt32(d * Math.Sin(3.14*i/9));
Point []a = {new Point(x1,y1)};
}意思是把x1,y1的坐标放到坐标数组中来,这样对不对?如果对,那是怎么样访问这个数组呢?如果不对,那又是怎么样呢?求指导~~~!!!~~~ 展开
3个回答
2013-05-16
展开全部
我来举个例子给你
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
bool b = true;
static int m =0, n = 80;
private void Form1_Paint(object sender, PaintEventArgs e)
{
if (b)
{
int x = 240, y = 120, k=0,d = 100, x1, y1;
Point[] a = new Point[18];
Graphics g = this.CreateGraphics();
Pen p = new Pen(Color.Red, 1);
p.DashStyle = DashStyle.Solid;
for (int i = 0; i < 18; i++)
{
x1 = x + Convert.ToInt32(d * Math.Cos(3.14 * i / 9));
y1 = y + Convert.ToInt32(d * Math.Sin(3.14 * i / 9));
a[i] = new Point(x1, y1);
}
for (int i = 0; i < 18; i++)
for (int j = i; j < 18; j++)
{
k++;
p.Color = Color.FromArgb(k+3, m, k+n);
g.DrawLine(p, a[i], a[j]);
}
}
这个是画一个18边形,没两点都连接的图来的,其中就用到了坐标数组,慢慢看,不懂再问···
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
bool b = true;
static int m =0, n = 80;
private void Form1_Paint(object sender, PaintEventArgs e)
{
if (b)
{
int x = 240, y = 120, k=0,d = 100, x1, y1;
Point[] a = new Point[18];
Graphics g = this.CreateGraphics();
Pen p = new Pen(Color.Red, 1);
p.DashStyle = DashStyle.Solid;
for (int i = 0; i < 18; i++)
{
x1 = x + Convert.ToInt32(d * Math.Cos(3.14 * i / 9));
y1 = y + Convert.ToInt32(d * Math.Sin(3.14 * i / 9));
a[i] = new Point(x1, y1);
}
for (int i = 0; i < 18; i++)
for (int j = i; j < 18; j++)
{
k++;
p.Color = Color.FromArgb(k+3, m, k+n);
g.DrawLine(p, a[i], a[j]);
}
}
这个是画一个18边形,没两点都连接的图来的,其中就用到了坐标数组,慢慢看,不懂再问···
展开全部
1.下面是定义一个结构体
struct HSI
{
public int hue;
public int saturation;
public int intensity;
}
Class Test2
{
HSI[] hsi = new HSI[image.width*image.height];
int hue;
int saturation;
int intensity;
hsi[0].hue = hue;
hsi[0].saturation = saturation;
hsi[0].intensity = intensity;
hsi[1].hue = hue;
//这样使用结构数组
}
struct HSI
{
public int hue;
public int saturation;
public int intensity;
}
Class Test2
{
HSI[] hsi = new HSI[image.width*image.height];
int hue;
int saturation;
int intensity;
hsi[0].hue = hue;
hsi[0].saturation = saturation;
hsi[0].intensity = intensity;
hsi[1].hue = hue;
//这样使用结构数组
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-05-16
展开全部
double [] x;
double [] y;
double [] y;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询