涉及函数在程序中与主函数的位置关系
#include <stdio.h>
int max(int a,int b)
{
int ret;
if(a>b){
ret = a;
}
else ret = b;
return ret;
}
int main()
{
int a,b,c;
a = 5;
b = 6;
c = max(10,12);
c = max(a,b);
c = max(c,23);
printf("%d\n",max(a,b));
return 0;
}
以上是将定义函数放于主函数之前
int max(int a,int b);
int main()
{
int a,b,c;
a = 5;
b = 6;
c = max(10,12);
c = max(a,b);
c = max(c,23);
printf("%d\n",max(a,b));
return 0;
}
int max(int a,int b)
{
int ret;
if(a>b){
ret = a;
}
else ret = b;
return ret;
}