return 作用?
#include <stdio.h>
int getGirth(int a,int b,int c)
{
? ? if( (a+b)<=c || (a+c)<=b || (b+c)<=a ) ? //判斷是否為三角形
? ? {
? ? ? ? printf("不構(gòu)成三角形\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)); ?//調(diào)用周長函數(shù)
? ? return 0;
}
當(dāng)中return cirf;是什么意思?
2016-03-25
將函數(shù)值返回給調(diào)用者