Cod sursa(job #1941947)

Utilizator cosminbxCosmin Banu cosminbx Data 27 martie 2017 18:19:56
Problema A+B Scor 100
Compilator c Status done
Runda Arhiva de probleme Marime 0.58 kb
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int ret = 0;

    FILE *fin = NULL;
    FILE *fout = NULL;

    int a, b;

    fin = fopen("adunare.in", "r");
    if (fin == NULL) {
        ret = -1;
        goto exit;
    }

    if (2 != fscanf(fin, "%d %d", &a, &b)) {
        ret = -1;
        goto exit;
    }

    fout = fopen("adunare.out", "w");
    if (fout == NULL) {
        ret = -1;
        goto exit;
    }
    fprintf(fout, "%d", a + b);

exit:

    if (fin != NULL) {
        fclose(fin);
    }

    if (fout != NULL) {
        fclose(fout);
    }

    return ret;
}