03 2017 档案
摘要:#include #include #include #include typedef struct in { int x; int y; }In; typedef struct char_ { char ch[100]; }Char_; //对字符串排序函数 int ptr_7(const void *a, const void *b) { return ...
阅读全文
摘要:#include #include #include typedef struct edge { int vex; edge *next; }Edge; typedef struct vex { int data; Edge *firstchild; }Vex; typedef struct vexedge { int vexnum, edgenum...
阅读全文
摘要:#include #include #include /* 利用十字链表存储有向图,可用于同时查找某个顶点的出度与入度; */ typedef struct edge {//顶点表 int headvex, tailvex;//headvex弧的七点在顶点表中的下标,tailvex是边的重点在顶点表中的下标 edge *headlink, *taillink;//headl...
阅读全文
摘要:煤球数目 有一堆煤球,堆成三角棱锥形。具体: 第一层放1个, 第二层3个(排列成三角形), 第三层6个(排列成三角形), 第四层10个(排列成三角形), .... 如果一共有100层,共有多少个煤球? 请填表示煤球总数目的数字。 注意:你提交的应该是一个整数,不要填写任何多余的内容或说明性文字。 #include #include int feio(int n) { if ...
阅读全文
摘要:/* 大数相乘: 因为是大数,乘积肯定超出了能定义的范围,因此考虑用数组存储,定义三个数组,分别存储乘数,被乘数和积。 规则与平常手算一样,从个位开始分别与被乘数的每一位相乘,但是有一点不同的是:我们先不考虑进位。直接将 个十百千位存储在乘积数组中。乘数的每一位与被乘数相乘时应向左移一位。对应为相加结果存储在乘积数组中, 最后统一考虑进位问题 */ #include #include int...
阅读全文
摘要:/*背包问题: 背包所能容纳重量为10;共五件商品,商品重量用数组m存储m[5]={2,2,6,5,4}, 每件商品的价值用数组n存储,n[5]={6,3,5,4,6};求背包所能装物品的最大价值。 */ #include #include int main() { int m[5] = { 2,2,6,5,4 }, n[5] = { 6,3,5,4,6 }; int flag[...
阅读全文