#include
int main()
{
int a, b, c;
if (a + b)
{
c = add main(a,b);
printf("c = %d\n",add main(a, b));
}
else
{ c = sub main(a,b);
printf("c = %d\n",sub main(a, b));
}
}
add main(int a, int b)
{
return a + b;
}
sub main(int a, int b)
{
return a - b;
}
沒有add和sub類型,而且main不要用來做函數名,函數沒有先聲明應該都放main函數前面,還有就是include後面最好寫清楚頭文件名。代碼給你改好放在這裡了:
#include<stdio.h>
int add(int a, int b)
{
return a + b;
}
int sub(int a, int b)
{
return a - b;
}
int main()
{
int a, b, c;
if (a + b)
{
c = add(a,b);
printf("c = %d\n",add(a, b));
}
else
{ c = sub(a,b);
printf("c = %d\n",sub(a, b));
}
}