/*编写一个程序求满足以下公式的变量 k 的最大值。
2^k<=m
其中, m 是程序输入的一个正整数。*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
unsigned m;
int k = 0, temp = 1;
printf("Please input a number:");
scanf("%d", &m);
while (temp <= m)
{
temp = temp * 2;
k++;
}
printf("Max is %d\n", k-1);
system("pause");
return 0;
}
黄迪明3.9
最新推荐文章于 2023-03-02 21:22:24 发布