c++求幂次方

来源:互联网 发布:macbook air如何写编程 编辑:程序博客网 时间:2024/05/17 22:41

比如说求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("%d\n",ans);while(true);return 0;}



0 0