随笔分类 -  C

摘要:/* 输入一个正数x和一个正整数n,求下列算式的值。 x - x2/2! + x3/3! + ... + (-1)n-1xn/n! 要求定义两个调用函数:fact(n)计算n的阶乘 mypow(x,n)计算x的n次幂(即x^n),两个函数的返回值类型是double。(×输出保留4位小数) 计算分析: 阅读全文
posted @ 2021-09-23 17:22 windin 阅读(346) 评论(0) 推荐(0)
摘要:/* Consider the following algorithm to generate a sequence of numbers. Start with an integer n. If n is even, divide by 2. If n is odd, multiply by 3 阅读全文
posted @ 2021-02-02 21:39 windin 阅读(103) 评论(0) 推荐(0)
摘要:#include <stdio.h> #define N 6 void input(int *p,int n); void ouput(int *p,int n); int main(){ int a[N]; input(a,N); ouput(a,N); return 0; } void inpu 阅读全文
posted @ 2021-02-02 17:09 windin 阅读(407) 评论(0) 推荐(0)
摘要:/* calculate a num y which is base x to exp n 2^n=2*2^n-1 (n is an odd) 2^n=2^(n/2)*2^(n/2) (n is an even) judge method: if:b&1 b%2==1 (b is an odd) else:!(b&1) b%2==0 (b is... 阅读全文
posted @ 2018-06-15 17:53 windin 阅读(350) 评论(0) 推荐(0)
摘要:定义: 完全数:所有的真因子(即除了自身以外的约数)的和,恰好等于它本身。例如:第一个完全数是6,它有约数1、2、3、6,除去它本身6外,其余3个数相加,1+2+3=6。第二个完全数是28,它有约数1、2、4、7、14、28,除去它本身28外约数相加=28。 性质: (1)所有的完全数都是三角数。例 阅读全文
posted @ 2018-06-15 17:18 windin 阅读(1554) 评论(0) 推荐(0)