摘要: /* 输出斐波拉数列的前n个数(n>=2) F(1)=1;F(2)=1; F(n)=F(n-1)+F(n-2); */ #include <stdio.h> int main(){ int f1=1,f2=1,f3,i,n; printf("输入斐波拉数列中的前n个数(n>=2):"); scanf 阅读全文
posted @ 2020-08-19 13:06 薄眠抛却陈年事。 阅读(268) 评论(0) 推荐(0) 编辑
摘要: //计算n!函数递归调用 #include <stdio.h> int fun(int n){ int a; if(n<0){ printf("n<0.data error!"); }else if(n==1){ a=1; }else if(n==0){ a=0; }else{ a=fun(n-1) 阅读全文
posted @ 2020-08-19 13:03 薄眠抛却陈年事。 阅读(519) 评论(0) 推荐(0) 编辑
摘要: /* 函数功能插入一个数,按照原来的排序规律排序 */ #include<stdio.h> void fun(int a[],int n,int b){ int i,j; for(i=0;i<5;i++){ if(b>a[i]&&b<a[i+1]){ for(j=5;j>i+1;j--) a[j]= 阅读全文
posted @ 2020-08-19 13:02 薄眠抛却陈年事。 阅读(296) 评论(0) 推荐(0) 编辑
摘要: /* 将数组中的数逆序重新排放 */ #include<stdio.h> void fun(int a[],int n){ int i,t; for(i=0;i<n/2;i++){ t=a[i]; a[i]=a[n-1-i]; a[n-1-i]=t; } } int main(){ int a[5] 阅读全文
posted @ 2020-08-19 13:01 薄眠抛却陈年事。 阅读(435) 评论(0) 推荐(0) 编辑