园代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SJ {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e) {
int x, y;
for (int i = 0; i < 100; i++) {
x = 1;
y = 1;
while (x < 339) {
button1.Location = new Point(x, y);
x++;
Thread.Sleep(7);
}
while (y < 268) {
button1.Location = new Point(x, y);
y++;
Thread.Sleep(7);
}
while (x > 1) {
button1.Location = new Point(x, y);
x--;
Thread.Sleep(7);
}
while (y > 1) {
button1.Location = new Point(x, y);
y--;
Thread.Sleep(7);
}
}
}
}
}
程序无法关闭