有下面伪代码
int func(int a,int b) { int x=a; int y=b; int r=1; while(y>0) if(y为偶数) { x=x*x; y=y/2; } else { r=r*x; y=y-1; } return r; }
(1) 当 b为非负整数时,func(a,b)的返回值为何?
(2) 给出代码中while循环的旬环不变量。
这道题你会答吗?花几分钟告诉大家答案吧!
扫描二维码,关注牛客网
下载牛客APP,随时随地刷题