代码:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>int jiecheng(int n){if(n<=1)return 1; return n*jiecheng(n-1);
}int sum(int n){if(n<=0)return 0;return n+sum(n-1);
}int feb(int n){if(n<=2)return 1;elsereturn feb(n-1)+feb(n-2);
}void exchange(int n){if(n==0)return ;else{ exchange(n/2);printf("%d",(n%2));}
}int sumge(int n){if(n==0)return 0;elsereturn n%10+sumge(n/10);
}int cheng(int n){if(n==0)return 1;elsereturn n%10*cheng(n/10);
}void reverse(char *arr){int high=strlen(arr)-1;int low=0;while(low<high){int temp=*(arr+low);*(arr+low)=*(arr+high);*(arr+high)=temp;high--;low++;}puts(arr);
}int main(int argc,const char *argv[]){printf("%d\n",jiecheng(5));printf("%d\n",sum(5));for(int i=1;i<=5;i++)printf("%d\t",feb(i));puts("");printf("%d\n",sumge(234));printf("%d\n",cheng(234));char str[]="hello";reverse(str);return 0;
}
程序: