下面的函数实现在一个固定的数上加上一个数,有什么错误,改正 int add_n(int n) { static int i=100; i+=n; return i; }
答:因为static使得i的值会保留上次的值。去掉static就可了