倒數第二行中的getGirth(a,b,c)為什么不能寫成getGirth(cirf)
#include <stdio.h>
int getGirth(int a,int b,int c)
{
? ? if( (a+b)<=c || (a+c)<=b || (b+c)<=a )? ?//判斷是否為三角形
? ? {
? ? ? ? printf("不構成三角形\n");
? ? ? ? return 0;? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? }
? ? else
? ? {
? ? ? int cirf = a+b+c ;? ? ?
? ? ? return cirf;
? ? }
? ? ? ?
}
int main()
{
??
? ? int a, b, c;
? ? a = 3;
? ? b = 4;
? ? c = 5;
? ? printf("三角形的周長是:%d\n", getGirth(a,b,c));
??
? ? return 0;
}
2018-07-21
getGirth()?函數中的參數一開始就已經是定義了abc,而且,這個還需要一步判斷才能決定是否能進行周長的運算,再則,直接調用肯定也找不到這個東西,這個整型是定義在getGirth()函數里面的,你在main()函數里找不到。