..........................................我无语了,杂就看不到捏,想捶自己一顿编译也不提示5555555555白白浪费时间
晕,我脑袋有点不灵光啊这办法太妙了
include<stdio.h>main(){ int n,k,i=1; scanf("%d",&n); k=n/2; while ((k)!=1) { k=k/2; i++; } i++;
printf("\n%d\n",i); }
[此贴子已经被作者于2006-2-19 22:42:23编辑过]
include<stdio.h>main(){int n,k,i=1;scanf("%d",&n);k=n/2; while ((k)!=1) { k=k/2; i++; }i++;
printf("\n%d\n",i);}
运行不了啊,/2的次数能判断位吗?比如64要/2多少次啊,
#include <stdio.h>void main(){ int n,count=0;
scanf("%d",&n); /*输入超出范围未考虑*/
do{ n=n/10; count++; }while(n!=0); printf("count=%d\n",count);
getch();}
不好意思~昨天晚上网络出了问题~我们学校又要断电。。我没改。。看下面这个:include<stdio.h>main(){ int n,k,i=1; //也可以把n设为无符号的整型 scanf("%d",&n); if (n>1) { k=n/2; while ((k)!=1) { k=k/2; i++; } i++; } else if ((n>=0)&&(n<=1)) i=1; printf("\n%d\n",i);}