![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C
文章平均质量分 66
普通网友
这个作者很懒,什么都没留下…
展开
-
<Fundamentals of Data Structures in C> 2.8 附加习题
【习题9】随机漫步 random walk问题#include #include #include #define MAX_N 50#define MAX_ITERATION 50000int wander[MAX_N][MAX_N] = {0};int imove[] = {-1, 0, 1, 1, 1, 0, -1, -1};int jmove[] = {1, 1原创 2017-04-09 19:24:24 · 190 阅读 · 0 评论 -
<Fundamentals of Data Structures in C> 1.4.3 渐进记号
【例1-20】全排列的时间复杂度O(n*(n!))#include #include #define SWAP(A,B,C) ((C = A),(A = B),(B = C))void perm(char *,int,int);int main(void){ char *list = "abcdefghijklmn"; int len = strlen(list);原创 2017-03-13 21:59:05 · 194 阅读 · 0 评论 -
<Fundamentals of Data Structures in C> 1.2 算法描述 2
【练习10】Ackerman函数的递归实现与迭代实现。Ackerman(4,1)以上都无法计算出来。原文地址:http://blog.csdn.net/pku_zzy/article/details/519337911、递归实现int ack(int m,int n){ if (m==0) return n+1; else if (n==0)转载 2017-03-12 19:17:24 · 193 阅读 · 0 评论 -
<Fundamentals of Data Structures in C> 1.2 算法描述
【习题2】霍纳规则 Horner's method:用来简化朴素多项式的求值,在中国叫秦九韶算法。霍纳规则是一种将一元n次多项式求值问题转化为n个一次式算法。其大大简化了计算过程,即使在现代,利用计算机解决多项式的求值问题时,霍纳规则依然是最优的算法规则。霍纳规则是采用最少的乘法运算策略,求多项式A(x) = anxn+ an-1xn-1+...+ a1x + a0在x转载 2017-03-05 22:03:14 · 375 阅读 · 0 评论 -
<The C programming language> 语言测试
测试以下内容:1、三字符序列;2、wchar_t3、打印输出g/p/o/x#include #include int main(void){ double a; int *pi,buf[20]; int no; wchar_t chi; chi = '鬼'; printf("鬼 = %c\t??=#??/n%d\n",chi,chi); pi = bu原创 2017-02-26 22:29:06 · 99 阅读 · 0 评论 -
<Fundamentals of Data Structures in C> 1.5 性能测量 习题5
将顺序查找函数的迭代程序(程序1-24)转换成等价的递归程序,测量其性能。#include #include #define MAX_SIZE 10001#define ITERATION 13int seqsearch(int *,int,int);int seqsearch2(int *,int,int);int main(void){ int n_size[]原创 2017-03-18 14:43:06 · 147 阅读 · 0 评论 -
<The C programming language> 5.11 函数指针 “函数名称就是函数的地址?”
qsort1((void **) lineptr, 0, nlines - 1, (int (*)(void *, void *))(numeric ? numcmp : strcmp));Wedit output window build: Sun Feb 19 10:26:10 2017Error h:\c_workcarbin\mytest.c: 26 operands o原创 2017-02-19 14:45:29 · 231 阅读 · 0 评论