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

求高手指教,为什么是runtime error

Posted by wxyyxw09090 at 2012-01-23 21:57:51 and last updated at 2012-01-23 21:58:17
我觉得我写得没问题,用用C语言的,可为什么是runtime error啊
代码如下:

#include<stdio.h>

void prison(int n);

void main()
{
	int num;
	int n[100] = {0};
	int i;
	scanf("%d", &num);
	for(i = 1; i <= num; i ++)
	{
		scanf("%d", &n[i]);
	}
	for(i = 1; i <= num; i ++)
		prison(n[i]);
}

void prison(int n)
{
	int prisoner[101] = {0}; //'0' represents that the door is locked;'1' represents the door is unlocked
	int i, j;
	int count = 0;//record the final number of the doors unlocked

	for(i = 1; i <= n; i ++)
		for(j = 1; j <= n; j ++)
		{
			if((j % i) == 0)
				prisoner[j] = (prisoner[j] + 1) % 2;
		}
	for(i = 1; i <= n; i ++)
	{
		if(prisoner[i] == 1)
			count ++;
	}
	printf("%d\n", count);
}

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