> 其他 >
.编写程序,计算2的n次方.其中n为整数.注意n可能是正整数、负整数或0.
人气:488 ℃ 时间:2020-06-23 07:37:55
解答
#include#includevoid main(){int n,s;double s0;printf("本程序计算2的n次方,请输入次数n:\n");scanf("%d",&n);if(n>=0){s=pow(2.0,n);printf("%d\n",s);}else{s0=1.0/pow(2.0,abs(n));printf("%f\n",s0);}}...
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版