![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C
文章平均质量分 57
aasyk2love
这个作者很懒,什么都没留下…
展开
-
约瑟夫环问题两解
原文:http://www.cnblogs.com/EricYang/archive/2009/09/04/1560478.html 继续笔试准备ing……分享一下昨天做到的其中一题,其实题目很老,也做过n遍了,但复习起来也是颇有韵味,同时还发现另一种妙解,感觉不错的。 问题描述: 约瑟夫环问题(Josephus) 用户输入M,N值,从1至N开始顺序循环转载 2013-06-11 20:24:56 · 538 阅读 · 0 评论 -
穷举法
#include /* 穷举法 Tom五本书,给3位同学的分法。 */ int main() { int i,j,k; for(i=0;i<5;i++) { for(j=0;j<5;j++) { for(k=0;k<5;k++) if(i!=j && i!=k && j!=k) { printf("%d %d %d\n",i,j,k); }原创 2013-06-21 23:28:06 · 397 阅读 · 0 评论 -
递归与分治
#include /* 递归与分治 求一个整数的全部划分数 6=6 6=5+1 6=4+2 6=4+1+1 6=3+3 6=3+2+1 6=3+1+1 6=2+2+2 6=2+2+1+1 6=2+1+1+1+1 6=1+1+1+1+1+1 */ int part(int n,int m) { if(m==1) return 1; if(m>n) return part(n,n); if(原创 2013-06-21 23:59:28 · 429 阅读 · 0 评论 -
递归与分治2
#include /* 递归 实现折半查找 */ //普通折半查找 int binSearch_Normal(int A[],int n,int e) { int low = 0,high = n-1,mid; while(low <= high) { mid = (low + high) / 2; if(A[mid] == e) return mid; if(e > A原创 2013-06-22 00:32:03 · 375 阅读 · 0 评论 -
简单的str函数重写
#include #include /* 简单的str函数重写 */ int my_atoi( const char *str ) { if (str == 0 ) return 0; int nRet = 0; bool bFlag = false; int i=0; if (strlen(str) == 0) return原创 2013-06-18 14:04:06 · 547 阅读 · 0 评论 -
链表
#include #include /* 链表及其操作 */ /*定义*/ typedef struct node{ int data;//数据域 struct node *next;//指针域 }LNode,*LinkList; /*遍历链表*/ void printLinkList(LinkList p){ if(!p) exit(0); printf("----------原创 2013-06-15 20:31:27 · 367 阅读 · 0 评论 -
局部证明哥德巴赫猜想
#include #include /* 哥德巴赫猜想的局部证明(1-1000000已证) */ /*函数声明*/ int testifyGB_Guess(int low ,int high); int isGoldbach(int n); int isPrime(int n); /*证明low——high是否符合*/ int testifyGB_Guess(int low ,int hig原创 2013-06-15 21:34:37 · 651 阅读 · 0 评论 -
静态顺序表
#include #include /* 静态顺序表及其操作 */ #define MaxSize 10 /*静态定义顺序表*/ int Sqlist[MaxSize]={4,5,6,7,8}; int len=5; /*遍历*/ void PrintElem(int Sqlist[],int n){ int i; for(i=0;i<n;i++) { printf("%d\n",原创 2013-06-15 18:53:05 · 478 阅读 · 0 评论 -
普通寻路算法
#include /* 普通寻路算法 回溯法,近似穷举 找到的路径不一定是最短路径 */ #define MAX_NUMBER_LENGTH 6 void print_path(); /*用矩阵表示地图:其中1表示路,0表示没有路,2表示终点,起始地点为(1,0)*/ static int gPath[MAX_NUMBER_LENGTH][MAX_NUMBER_LENGTH] =转载 2013-06-12 22:01:23 · 491 阅读 · 0 评论 -
流程控制
Description 输入10个数,找出出现次数最多的数 (如果多个并列,则按数字出现顺序分别输出) 比如: 输入:1 5 27 33 24 1 27 18 1920 输出: 1 27 输入: 3 21 44 5 21 9 21 2 80 输出: 21 Input 1 1 3 4 5 6 7 8 9 0原创 2013-06-11 21:37:34 · 706 阅读 · 0 评论 -
流程控制 NN矩阵
#include /*输入两个数,第一个数决定一个nXn的矩阵,第二个数决定从1开始赋值,赋值的上限 5 18 输出: 1 2 3 4 5 16 17 18 0 6 15 0 0 0 7 14 0 0 0 8 13 12 11 10 9 */ #define MAX 100 void main() { int a[MAX][MAX]={0};原创 2013-06-11 21:54:20 · 747 阅读 · 0 评论 -
C/C++ 内存分配方式,堆区,栈区,new/delete/malloc/free
http://blog.csdn.net/rujielaisusan/article/details/4622197 内存分配方式 内存分配方式有三种: [1] 从静态存储区域分配。内存在程序编译的时候就已经分配好,这块内存在程序的整个运行期间都存在。例如全局变量, static 变量。 [2] 在栈上创建。在执行函数时,函数内局部变量的存储单元都可以在栈上创建,函数执行结束时这些存储转载 2013-06-29 17:14:31 · 410 阅读 · 0 评论