[ create a new paste ] login | about

Link: http://codepad.org/0i4ByGfl    [ raw code | output | fork ]

C++, pasted on Dec 18:
#include<iostream>
using namespace std;

//絶対値を求める
int abs(int a){
	if(a<0){
		return -a;
	}else{
		return a;
	}
}

double abs(double a){
	if(a<0){
		return -a;
	}else{
		return a;
	}
}

//入力
int input(int& i,double& d){
	cout<<"整数値を入力して下さい > "<<flush;
	cin>> i;
	if(i==0){
		return 0;
	}

	cout<<"小数値を入力して下さい > "<<flush;
	cin>> d;
	if(d==0){
		return 0;
	}

	return 1;
}

//絶対値の表示
void showabs(int i,double d){
	cout<<i<<"の絶対値は"<<abs(i)<<"です。"<<endl
		<<d<<"の絶対値は"<<abs(d)<<"です。"<<endl;
}

int main(){
	int i;
	double d;

	while(input(i,d) != 0){
		showabs(i,d);
	}
}


Output:
1
2
3
In function 'int abs(int)':
Line 5: error: declaration of 'int abs(int)' throws different exceptions
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: