ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Common Board

I always got a error of restricted functions!what's wrong!below is my code:
Posted by Vinsent 27 Mar 2002 06:36
#include "stdio.h"

int Paritition(long array[],int begin,int end)
{
    int i,j;
    long temp,temp2;
    temp=array[begin];
    i=begin+1;
    j=end;
    while(1)
    {
        while(array[i]<temp)
            i++;
        while(array[j]>temp)
            j--;
        if(i>=j)
            break;
        temp2=array[i];
        array[i]=array[j];
        array[j]=temp2;
    }
    temp2=array[j];
    array[j]=temp;
    array[begin]=temp2;
    return j;
}

void quicksorta(long array[],int begin,int end)
{
    int iGenerate;
    if(begin<end)
    {
        iGenerate=Paritition(array,begin,end);
        quicksorta(array,begin,iGenerate-1);
        quicksorta(array,iGenerate+1,end);
    }
}

main()
{
    int i,count;
    long a[20],extra;
    FILE *pf;
    pf=fopen("input.dat","r");
    if(pf==NULL)
    {
        printf("File can't be opend!");
        return;
    }
    fscanf(pf,"%d",&count);
    for(i=0;i<count;i++)
        fscanf(pf,"%ld",&a[i]);
    for(;i<20;i++);
        a[i]=0;
    fclose(pf);
    quicksorta(a,0,count-1);
    extra=a[count-1];
    for(i=count-2;i>=0;i--)
    {
        if(extra>0)
          extra-=a[i];
        else
          extra+=a[i];
    }
    pf=fopen("output.dat","w");
    fprintf(pf,"%ld",extra>=0?extra:-extra);
}
Re: I always got a error of restricted functions!what's wrong!below is my code:
Posted by Sam Green 27 Mar 2002 07:41
don't open file , use standard input/output here
Re: I always got a error of restricted functions!what's wrong!below is my code:
Posted by Vinsent 27 Mar 2002 08:05
> don't open file , use standard input/output here
Thank you
Posted by Vinsent 27 Mar 2002 08:05