自定义函数:
函数的好处:封装要实现的功能,在程序中需要实现相同功能的地方通过重复调用该函数,从而减少程序中重复编写相同功能的代码,大大提高程序编写效率. 1.输入两个整数,输出他们的和。 #include
using namespace std; int f(int x,int y){ int k; k=x+y; return k; } int main(){ int a,b,c; cin>>a>>b; c=f(a,b); cout<
using namespace std; int f(int &x,int y){ int k; k=x+y; x++; y++; return k; } int main(){ int a,b,c; cin>>a>>b; c=f(a,b); cout<