Cod sursa(job #1715988)

Utilizator andreigasparoviciAndrei Gasparovici andreigasparovici Data 11 iunie 2016 19:36:45
Problema A+B Scor 100
Compilator c Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <stdio.h>
#include <stdlib.h>
#define INPUT_FILE "adunare.in"
#define OUTPUT_FILE "adunare.out"
FILE *f,*g;
int next_int()
{
    int n=0;
    char c='1';
    while(c>='0' && c<='9' &&  !feof(f))
    {
        fread(&c,1,sizeof(char),f);
        if(c>='0' && c<='9' && !feof(f))
            n=n*10+(c-'0');
    }
    return n;
}
int s;

int main()
{
    f=fopen(INPUT_FILE,"rb");
    while(!feof(f))
        s+=next_int();
    fclose(f);
    g=fopen(OUTPUT_FILE,"wb");
    fprintf(g,"%d\n",s);
    fclose(g);
    return 0;
}