#include<stdio.h>
int main()
{
int num,count=0,i=0,ret=0;
scanf("%d",&num);
count=num;
while(num>1)
{
num/=2;
ret++;
}
printf("log2 of %d = %dn",count,ret);
return 0;
}
/*
64
log2 of 64 = 6
Press any key to continue
*/
//注意:在两个数做运算时,只要有一个是浮点数,计算的结果均为浮点数!
转载于:https://www.cnblogs.com/gcter/p/5729712.html
最后
以上就是香蕉白云最近收集整理的关于C语言之计算log2的全部内容,更多相关C语言之计算log2内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复