| ||||||||||
| 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 | |||||||||
求高手指教,为什么是runtime error我觉得我写得没问题,用用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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator