谁能帮把我的java代码缩短也

来源:百度知道 编辑:UC知道 时间:2024/09/22 07:54:10
import sheffield.*;
import java.util.*;
import sheffield.EasyGraphics;

public class tonglu {

public static void main(String[] args) {

final int SIZE = 400;
final int PIX = 6;

EasyGraphics g = new EasyGraphics(SIZE, SIZE);
g.moveTo(SIZE/2, SIZE/2);

int[][] oldc = new int[SIZE][SIZE];
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
oldc[i][j] = 0;
}
}
oldc[SIZE / 2][SIZE / 2] = 1;
int x = SIZE / 2;
int y = SIZE / 2;

for (int k = 1; k < (SIZE / PIX) * 10000000; k++) {

if ((oldc[x][y - PIX]) == 1 && (oldc[x][y + PIX] == 1) && (oldc[x - PIX][y] == 1) && (oldc[x + PIX][y] == 1)) {
break;
}
Random r = new Random();
int a = r.nextIn

看的痛苦
建议你自己先在算法上多设计下
然后再写

一个简单的贪食蛇,修正了泛型,完全支持 JDK 1.4,里边有你要的思路:
http://hi.baidu.com/ttbet/blog/item/a75045afaf7088cb7dd92a78.html

看不懂!

这个EasyGraphics是什么??