Pagini recente » Cod sursa (job #433857) | Cod sursa (job #2448142) | Rating Marina Teodor (teodor1923) | Cod sursa (job #2322820) | Cod sursa (job #1941947)
#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;
}