-
Notifications
You must be signed in to change notification settings - Fork 0
/
fibsys.c
58 lines (48 loc) · 961 Bytes
/
fibsys.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <stdio.h>
main()
{
unsigned long x,b,a,c;
unsigned long long i=0,j,s=0,n=0;
scanf("%ld", &x);
if (x == 0)
printf("%c\n", '0');
else
{
while(x>0)
{
++i;
c=0;
b=1;
j=0;
while (c<=x)
{
if (c>0) a=c;
else a=1;
if ((c+b) <=x)
{
++j;
c+=b;
b=a;
} else break;
}
if (i==1)
{
s=j;
printf("%c", '1');
}
else
{
for (n=1;n<(s-j);++n)
printf("%c", '0');
s=j;
printf("%c", '1');
}
x -=c;
}
if ( j>1)
for ( n=0; n<(j-1); ++n)
printf("%c",'0');
printf("\n");
}
return 0;
}