喳喳小白来求助!!!机房上机伤不起!!!
c++吧
全部回复
仅看楼主
level 3
itismyland 楼主
[揉脸]
2012年04月24日 11点04分 1
level 3
itismyland 楼主
area.h
#include <iostream>
#include<cmath>
#define PI 3.14159
double area(double radius=0);
double area(double a,double b);
double area(double a,double b,double h);
double area(double a,double b,double c,int); area.cpp
#include <iostream>
#include "area.h"
double area(double radius){
return PI*radius*radius;
}
double area(double a,double b){
return a*b;
}
double area(double a,double b,double h){
return (0.5*(a+b)*h);
}
double area(double a,double b,double c,int){
double s=0.5*(a+b+c);
return sqrt(s*(s-a)*(s-b)*(s-c));
} Exp_2.cpp
#include <iostream>
#include "area.h"
using namespace std;
int main(){
cout<<"Area of point is:"<<area()<<endl;
cout<<"Area of square is:"<<area(1,1)<<endl;
cout<<"Area of circle is:"<<area(0.5)<<endl;
cout<<"Area of trapezium is:"<<area(1,0.5,1)<<endl;
cout<<"Area of triangle is:"<<area(1,sqrt(1+0.5*0.5),sqrt(1+0.5*0.5),0)<<endl;
return 0;
}
2012年04月24日 11点04分 2
level 3
itismyland 楼主
球大神指正错误
2012年04月24日 11点04分 3
level 3
itismyland 楼主
[揉脸]
2012年04月24日 11点04分 4
level 3
itismyland 楼主
错误多的想死
2012年04月24日 11点04分 5
level 3
itismyland 楼主
大婶。。。。。
2012年04月24日 11点04分 6
1