Cod sursa(job #561334)

Utilizator deszhtopSzabo Hunor deszhtop Data 19 martie 2011 20:34:34
Problema A+B Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.04 kb
#include <iostream>
using namespace std;
#include <fstream>
#include <limits>

class hiba1{};
class hiba2{};
class osszead{
	int a,b,ossz;
	hiba1 hiba;
	hiba2 hibaa;
public:
	osszead();
	void ab();
	void beleir();
};




osszead::osszead(){
	ifstream be ("adunare.in" , ifstream::in );
	be>>a;
	be>>b;
	ossz=0;
	be.close();
}

void osszead::ab(){
	/*nt m=numeric_limits<int>::max( );
	int mm=numeric_limits<int>::max( )-a-b;*/
	/*cout<<m<<endl<<mm;*/
	if ((a>0)&&(b>0))
		if (((((numeric_limits<int>::max( ))-a)-b)<0)){
			hiba1 hiba;
			throw hiba;}
	if ((a<0)&&(b<0))
		if (((((numeric_limits<int>::max( ))+a)+b)<0)){
			hiba2 hibaa;
			throw hibaa;}
	ossz=a+b;
}

void osszead::beleir(){
	ofstream ki("adunare.out");
	ki<<ossz;
	ki.close();
}

int main(){
	osszead obi;
	try{
		obi.ab();
		}
	catch (hiba1 hiba){
		cout<<"tul nagyok a szamok ne adj meg ekkora pozitiv szamokat";}
	catch (hiba2 hiba){
		cout<<"tul nagyok a szamok ne adj meg ekkora negativ szamokat";}

	obi.beleir();
	return 0;
}