Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
水题,输出弄错了,wa了2次,核心java代码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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator