1 #include<stdio.h> 2 int a[100]; 3 int main() 4 { 5 float n=0.17; 6 int index=0; 7 while(n) 8 { 9 float temp=n*2-1; 10 if(temp<0) 11 { 12 n=temp+1; 13 a[index]=0; 14 } 15 else 16 { 17 n=temp; 18 a[index]=1; 19 } 20 ++index; 21 } 22 23 int m=0; 24 while(m<index) 25 { 26 printf("%d",a[m]); 27 ++m; 28 } 29 printf("\n"); 30 return 0; 31 }
时间: 2024-10-10 21:51:44