✔ 最佳答案
//Power by Microsoft Visual Studio 2005
//可以使用 Dev-C++ 編譯此程式
#include<iostream>
#include<cstdlib>
#include<cmath>
using namespace std;
int main(int argc,char **argv){
//=====START=====//
double SIDE_LENGTH(double *p1,double *p2);
double A[]={1,1,1},B[]={-2,3,5},C[]={1,7,2};
printf("Length of AB= %lf\n",SIDE_LENGTH(A,B));
printf("Length of BC= %lf\n",SIDE_LENGTH(B,C));
printf("Length of CA= %lf\n",SIDE_LENGTH(C,A));
//=====END=====//
system("PAUSE");
return EXIT_SUCCESS;
}//主程式
double SIDE_LENGTH(double *p1,double *p2){
double sideLEN;
int i;
for(i=0,sideLEN=0;i<3;i++){
sideLEN+=pow(p1[i]+p2[i],2);
}
return sqrt(sideLEN);
}
小綿羊忘了如何算三維面積……