return后這里為什么要用cirf?
#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;//
#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;//這里為什么要用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;
}
? ? }
? ? ? ?
}
int main()
{
? ? /* 定義三角形三邊長 */
? ? int a, b, c;
? ? a = 3;
? ? b = 4;
? ? c = 5;
? ? printf("三角形的周長是:%d\n", getGirth( a, b, c)); ?//調(diào)用周長函數(shù)
? ? return 0;
}
2017-05-31
因為這個函數(shù)的目的就是計算周長,當然在最后要返回給主函數(shù)的是計算后周長的值。