Cod sursa(job #662747)

Utilizator ONEoo7Stefan Ghitescu ONEoo7 Data 16 ianuarie 2012 22:49:19
Problema A+B Scor 100
Compilator c Status done
Runda Arhiva de probleme Marime 0.53 kb
#include <stdio.h>
#include <stdlib.h>

#define LIMIT 1000000000
#define FILE_NAME "adunare.in"

int main()
{
	FILE *ifp = NULL;
	FILE *ofp = NULL;
	int a, b;
	
	if((ifp = fopen(FILE_NAME,"r")) == NULL){
		fprintf(stderr, "error: unable to open file %s\n", FILE_NAME);
		exit(1);
	}
	ofp = fopen("adunare.out","w");
	
	fscanf(ifp, "%d %d", &a, &b);
	if(a >= 0 && a < LIMIT || b >= 0 && b < LIMIT){
		fprintf(ofp, "%d\n", a + b);
	}
	else{
		fprintf(stderr, "error: limit exceeded\n");
		exit(1);
	}
	
	return 0;
}