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 Réponse
+ 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