比如说求x的y次方
#include<stdio.h>
//#include"1442.h"
int main(){
//int x = f1();
int x=2,y=10,ans=x;
y--;
while(y!=0){
if(y%2!=0){
ans = ans * x;
}
y /= 2;
x = x*x;
}
printf("%dn",ans);
while(true);
return 0;
}
最后
以上就是雪白蜡烛最近收集整理的关于c++求幂次方的全部内容,更多相关c++求幂次方内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复