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

ㄊㄉ題目內容 是題目1. 輸入三個數, 求其中最大數的演算法。
題目2. 輸入三個數, 判斷是否為三角形的三邊長的演算法 因為我還在學習 所以ㄆ太懂C語言程式要怎ㄇㄑ用 可以幫我解答ㄇ 文字敘述ㄝ可以 謝謝

2007-10-17 15:36:43 · 1 個解答 · 發問者 蔡耀德 1 in 電腦與網際網路 程式設計

1 個解答

#include
#include
#include
int getMax(int a, int b, int c){
return (a>b?(a>c?a:c):(b>c?b:c));
}
int chktri(int A, int B, int C){
return ((A+B)>C?((B+C)>A?((C+A)>B?1:0):0):0);
}
int main(int argc, char* argv[]){
//=====START=====//
int tri[3],i;
for(i=0;i<3;i++){
printf("Input %d number: ",i+1),scanf("%d",(tri+i));
}
printf("Max= %d\n",getMax(tri[0],tri[1],tri[2]));
printf("It is%s a Triangle.\n",(chktri(tri[0],tri[1],tri[2])?"":"n't"));
//=====END=====//
system("PAUSE");
return 0;
}

2007-10-17 16:13:44 · answer #1 · answered by Big_John-tw 7 · 0 0

fedest.com, questions and answers