1 条题解
-
0
C :
#include<stdio.h> int main(){ double h=100.0; int n=0; while(h>=0.5){ h=h/2.0; n++; } printf("%d",n); return 0; }C++ :
#include <iostream> #include <iomanip> #include <cmath> using namespace std; int main(){ double s=100,c=0; for(int i=1;i<=1000000;i++){ if(s>=0.5){ s/=2; c++; }else{ cout<<c; break; } } }Pascal :
var a:integer; begin a:=8; writeln(a); end.Java :
public class Main { public static void main(String[] args) { float l=100; int n=0; do{ l=l/2; n++; }while(l>=0.5); System.out.println(n); } }Python :
n=100 s=0 while n>=0.5: n=n/2 s+=1 print(s)
- 1
信息
- ID
- 61
- 时间
- 1000ms
- 内存
- 512MiB
- 难度
- 10
- 标签
- 递交数
- 5
- 已通过
- 3
- 上传者