English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

Use the array storage to store the input data(A,B and C points), and calculate the total side-length and area.
A(1,1,1)
B(-2,3,5)
C(1,7,2)

2006-12-02 21:00:53 · 1 個解答 · 發問者 TOMO Baby 4 in 電腦與網際網路 程式設計

1 個解答

//Power by Microsoft Visual Studio 2005
//可以使用 Dev-C++ 編譯此程式
#include
#include
#include
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);
}
小綿羊忘了如何算三維面積……

2006-12-16 13:10:52 · answer #1 · answered by Big_John-tw 7 · 0 0

fedest.com, questions and answers