分类: C/C++
2014-01-02 17:54:15
#include
int fibonacci(int n);
int main(int argc, char const *argv[])
{
/* code */
printf("input your month:");
int month =0;
scanf("%d",&month);
int number = fibonacci(month);
printf("rabbit number = %d\n",number );
return 0;
}
int fibonacci(int n){
if(n == 0 || n == 1){
return 1;
}else{
return fibonacci(n-1)+fibonacci(n-2);
}
}
#include
void move(int n, char a,char b,char c);
int main(int argc, char const *argv[])
{
/* code */
printf("input your move sheet :\n");
int n = 0;
scanf("%d",&n);
move(n,'A','B','C');
return 0;
}
void move(int n,char a,char b,char c){
if( n == 1)
{
printf(" move sheet %d from %c to %c \n",n,a,c);
}else{
move(n-1,a,c,b);
printf(" move sheet %d from %c to %c \n",n,a,c);
move(n-1,b,a,c);
}
}