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

为什么总是runtimeerror

Posted by zgd2009 at 2009-07-06 18:50:31
小弟的程序提交总是说RUNTIMEERROR
一般是什么原因造成的,小的新手,请多多指教,感激不尽!
#include<stdio.h>
#include<math.h>
#define arr 5
int test(int m)
{
   int i,n;
   n=(int)sqrt(m);

   for(i=2;i<=n;i++)
     {
        if(m%i==0)
        return 0;
        }
   return 1;

}
main()
{

   long a[arr],j,i=0,h,pos1,pos2,pos,k;

   while(1)
   {
     scanf("%ld",&a[i]);
      if(a[i]==0)
        break;
      if(a[i]<6||a[i]>=1000000)
        i--;
       if(a[i]%2)
       i--;
       i++;
     }

     for(h=0;h<i;h++)
     {

        for(j=2;j<=a[h]/2;j++)
        {
          pos1=test(j);

           if(pos1==1)
           {
              pos2=test(a[h]-j);
              if(pos2==1)
                 {
                   pos=j;
                   break;
                 }
           }
        }
     printf("%ld = %ld + %ld\n",a[h],pos,a[h]-pos);

     }
      getch();
}





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