#P1712. 自定义函数的参数传递.填空题

自定义函数的参数传递.填空题

阅读程序,判断程序的运行结果

程序1:值传递

#include<bits/stdc++.h>
using namespace std;
int f(int n)
{
	n++;
	return n;
}
int main()
{

	int n=7;
	
	cout<<f(n)<<endl;
	
	cout<<n;
	return 0;
}

程序运行,第一行输出{{ input(1) }}

第二行输出{{ input(2) }}

程序2:引用传递

#include<bits/stdc++.h>
using namespace std;
int f(int &n)
{
	n++;
	return n;
}
int main()
{

	int n=7;
	
	cout<<f(n)<<endl;
	
	cout<<n;
	return 0;
}

程序运行,第一行输出{{ input(3) }}

第二行输出{{ input(4) }}