ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Общий форум

I always got a error of restricted functions!what's wrong!below is my code:
Послано Vinsent 27 мар 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:
Послано Sam Green 27 мар 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:
Послано Vinsent 27 мар 2002 08:05
> don't open file , use standard input/output here
Thank you
Послано Vinsent 27 мар 2002 08:05