private
void
diaodu(
int
[] a)
{
int
i, j, x, y, q = 1, L, sub, small;
int
[] d=
new
int
[5];
for
(i = 0; i < f - 1; i++)
{
for
(j = 0; j < f - 1 - i; j++)
{
if
(a[j] > a[j + 1])
{ x = a[j]; a[j] = a[j + 1]; a[j + 1] = x; }
}
}
y =
this
.label1.Location.Y;
Console.WriteLine(
"第一层"
);
for
(j = 0; j < 21; j++)
{
if
(((y - b[j]) < 5&&(y - b[j])>=0) || ((y - b[j]) > -5&&(y - b[j])<0) )
{ d[1] = j;
break
; }
}
y =
this
.label3.Location.Y;
Console.WriteLine(y);
for
(j = 0; j < 21; j++)
{
if
(((y - b[j]) < 5 && (y - b[j]) >=0) || ((y - b[j]) > -5 && (y - b[j]) < 0))
{ d[2] = j;
break
; }
}
y =
this
.label4.Location.Y;
for
(j = 0; j < 21; j++)
{
if
(((y - b[j]) < 5 && (y - b[j]) >= 0) || ((y - b[j]) > -5 && (y - b[j]) < 0))
{ d[3] = j;
break
; }
}
y =
this
.label5.Location.Y;
for
(j = 0; j < 21; j++)
{
if
(((y - b[j]) < 5 && (y - b[j]) >= 0) || ((y - b[j]) > -5 && (y - b[j]) < 0))
{ d[4]= j;
break
; }
}
flag =d[1]; L = 1;
if
(d[1] - a[0] >=0)
{ small = d[1] - a[0]; }
else
{ small = a[0] - d[1]; }
for
(i = 1; i < 5; i++)
{
if
(d[i] - a[0] >=0)
{ sub = d[i] - a[0]; }
else
{sub= a[0] - d[i]; }
if
(small >sub)
{ small = sub; flag = d[i]; L = i; }
}
if
(L==1)
{
dianti1 = flag;
th1 = a[0];
if
(th1 >= dianti1)
{ k1 = th1 - dianti1; }
else
{ k1 = dianti1 - th1; }
this
.timer1.Interval = 500;
this
.timer1.Enabled =
true
;
}
if
(L == 2)
{
dianti2 = flag;
th2 = a[0];
if
(th2 >= dianti2)
{ k2 = th2 - dianti2; }
else
{ k2 = dianti2 - th2; }
this
.timer2.Interval = 500;
this
.timer2.Enabled =
true
;
}
if
(L == 3)
{
dianti3 = flag;
th3 = a[0];
if
(th3>= dianti3)
{ k3 = th3 - dianti3; }
else
{ k3 = dianti3 - th3; }
this
.timer3.Interval = 500;
this
.timer3.Enabled =
true
;
}
if
(L == 4)
{
dianti4 = flag;
th4 = a[0];
if
(th4 >= dianti4)
{ k4 = th4 - dianti4; }
else
{ k4 = dianti4 - th4; }
this
.timer4.Interval = 500;
this
.timer4.Enabled =
true
;
}
}
public
void
start1()
{
int
step = 21;
if
((th1 - dianti1) > 0)
{
this
.label1.Location =
new
Point(
this
.label1.Location.X,
this
.label1.Location.Y - step);
k1--;
if
(k1==0) {
this
.timer1.Enabled =
false
; }
}
else
{
this
.label1.Location =
new
Point(
this
.label1.Location.X,
this
.label1.Location.Y + step);
k1--;
if
(k1 == 0) {
this
.timer1.Enabled =
false
; }
}
}
public
void
start2()
{
int
step = 21;
if
((th2 - dianti2) > 0)
{
this
.label3.Location =
new
Point(
this
.label3.Location.X,
this
.label3.Location.Y - step);
k2--;
if
(k2 == 0) {
this
.timer2.Enabled =
false
; }
}
else
{
this
.label3.Location =
new
Point(
this
.label3.Location.X,
this
.label3.Location.Y + step);
k2--;
if
(k2 == 0) {
this
.timer2.Enabled =
false
; }
}
}
public
void
start3()
{
int
step = 21;
if
((th3 - dianti3) > 0)
{
this
.label4.Location =
new
Point(
this
.label4.Location.X,
this
.label4.Location.Y - step);
k3--;
if
(k3 == 0) {
this
.timer3.Enabled =
false
; }
}
else
{
this
.label4.Location =
new
Point(
this
.label4.Location.X,
this
.label4.Location.Y + step);
k3--;
if
(k3 == 0) {
this
.timer3.Enabled =
false
; }
}
}
public
void
start4()
{
int
step = 21;
if
((th4 - dianti4) > 0)
{
this
.label5.Location =
new
Point(
this
.label5.Location.X,
this
.label5.Location.Y - step);
k4--;
if
(k4 == 0) {
this
.timer4.Enabled =
false
; }
}
else
{
this
.label5.Location =
new
Point(
this
.label5.Location.X,
this
.label5.Location.Y + step);
k4--;
if
(k4 == 0) {
this
.timer4.Enabled =
false
; }
}
}