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

Re:什么是RUN TIME ERROR?郁闷死了!答案明明正确,为啥总是RUN TIME ERROR?大侠们帮小弟看一下,谢谢了!

Posted by 55168wswzw at 2007-04-18 20:46:17 on Problem 1218
In Reply To:什么是RUN TIME ERROR?郁闷死了!答案明明正确,为啥总是RUN TIME ERROR?大侠们帮小弟看一下,谢谢了! Posted by:042775 at 2006-03-31 20:41:24
> #include <stdio.h>
> #include <stdlib.h>
> int judge(int *a,int m);
> void init(int *a,int m);
> int judge(int *a,int m)
> {
> 	int i,j,sum=0;
> 	for(j=1;j<=m;j++)
> 		for(i=1;i<=m;i++)
> 			if(i%j==0)
> 			    if(*(a+2*i))
> 				     *(a+2*i)=0;
> 			    else
> 				   *(a+2*i)=1;
> 	for(i=1;i<=m;i++)
> 		if(*(a+2*i))
> 			sum++;
> 		return sum;
> }
> void init(int *a,int m)
> {
> 	int i;
> 	for(i=1;i<=m;i++)
> 		*(a+2*i)=0;
> }
> void main()
> {
> 	int n,i,j=0,m;
> 	int *a,*b;
> 	scanf("%d",&n);
> 	b=(int *)malloc(n*sizeof(int));
> 	while(j<n)
> 	{
> 		scanf("%d",&m);
> 		a=(int *)malloc((m+1)*sizeof(int));
> 		init (a,m);
> 		*(b+2*j)=judge(a,m);
> 		j++;
> 	}
> 	for(i=0;i<n;i++)
> 		printf("%d\n",*(b+2*i));
> }

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