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

过了的朋友看看这段代码错在哪?

Posted by BirdEgg at 2007-02-16 20:20:54 on Problem 1363
#include <stdio.h>
const int N = 1010;
int n, req[N], rail[N];

int main() {
	int i, j, top;
	while(scanf("%d", &n), n) {
		while(1) {
			for(i = 0; i<n; i++) {
				scanf("%d", req+i);
				if(req[i] == 0) break;
			}
			if(i != n) break;
			for(i = 1, j = 0, top = 0; i<=n && j<n; i++, j++)
				while(i != req[j] && i<=n && j<n)
					rail[top++] = i++;
			while(top > 0) {
				if(rail[top-1] == req[j++]) top--;
				else break;
			}
			if(top == 0) printf("Yes\n");
			else printf("No\n");
		}
		putchar('\n');
	}
	return 0;
}



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