Chinaunix首页 | 论坛 | 博客
  • 博客访问: 204847
  • 博文数量: 47
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1259
  • 用 户 组: 普通用户
  • 注册时间: 2013-07-24 10:20
文章分类
文章存档

2014年(21)

2013年(26)

分类: 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);

}

}

#include
#include
#include
int *swap(int *,int *);
typedef int* (*callback)(int *,int *);
int * func(callback,void *,void *);
int main(int argc, char const *argv[])
{
int c=4,d=5;
printf("input your number:\n\r");
scanf("%d,%d",&c,&d);
printf("c=%d,d=%d\n",c,d );
int *p =func(&swap,&c,&d);
printf("c=%d,d=%d\n",c,d );
}
int *swap(int *a,int *b){
int temp = *a;
*a=*b;
*b =temp;
return a;
}
int * func(callback call,void *a,void*b){
printf("execute callback function result:\n");
return call((int *)a,(int *)b);
}


阅读(1033) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~