Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

水题,输出弄错了,wa了2次,核心java代码

Posted by Jack_whj at 2014-01-06 15:55:46 on Problem 2632
static void run(int rob, int times) {
		while (times > 0) {
			moved(rob);
			for (int i = 1; i <= a; i++) {
				if (i != rob && x[i] == x[rob] && y[i] == y[rob]) {

					System.out.println("Robot " + rob + " crashes into robot "
							+ i);
					judge = false;
					return;
				}
				if (x[rob] < 1 || x[rob] > w || y[rob] < 1 || y[rob] > h) {
					System.out.println("Robot " + rob
							+ " crashes into the wall");
					judge = false;
					return;
				}
			}
			times--;
		}
	}

	static void moved(int j) {
		switch (der[j]) {
		case 0:
			y[j]++;
			break;
		case 1:
			x[j]++;
			break;
		case 2:
			y[j]--;
			break;
		case 3:
			x[j]--;
			break;
		default:
			break;
		}
	}
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator