week 1 problem set

Posted eleni

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了week 1 problem set相关的知识,希望对你有一定的参考价值。

 1 # include <stdio.h>
 2 int choose(int n);
 3 int main()
 4 
 5     int i=2,a=1,b=1,c=2;
 6     printf("%d\n%d\n",a,b);
 7     for (i=2;i<=10;i++)
 8     
 9         c=a+b;
10         a=b;
11         b=c;
12         printf("%d\n",c);
13         choose(c);
14     
15     return 0;
16 
17 
18 int choose(int n)
19 
20     while(n!=1)
21     
22         if(n%2==0)
23         
24             printf("%d\n",n);
25             n=n/2;
26         
27         else
28         
29             printf("%d\n",n);
30             n=3*n+1;
31         
32     
33     return 0;
34 

 

以上是关于week 1 problem set的主要内容,如果未能解决你的问题,请参考以下文章