0
how to use call by address or call by value to replace return functionďź
float cal(float x,int n){ int i; float ans=1;for(i=1;i<=n;i++){ ans=ans*x; }return ans;}
1 Answer
+ 2
ä˝ ĺŻäťĽç¨ ref
static void calRef(ref float x, int n)
{
int i;
float ans=1;
for(i=1;i<=n;i++) {
ans=ans*x;
}
x = ans;
}
https://code.sololearn.com/cTE03WmWHHNi/?ref=app