上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 14 下一页

2012年10月14日

归并排序

摘要: #include<iostream.h>void Merge(int *a,int p,int q,int r)//合并一个数组中前后两个有序序列{ //p,q,r是数组下标,a[p---q],a[q+1---r]两个有序 int *pA=a+p; int *pB=a+q+1; while(pA!=pB&&pB<=a+r) { if(*pA<=*pB) pA++; else { int temp=*pB; ... 阅读全文

posted @ 2012-10-14 22:59 为梦飞翔 阅读(193) 评论(0) 推荐(0)

2012年10月9日

N皇后问题

摘要: #include <IOSTREAM.H>#include <MATH.H>#define LENGTH 8int num=0;int SuccessInsert(int (*a)[LENGTH],int x,int y){ for (int i=0;i<LENGTH;i++) { for (int j=0;j<LENGTH;j++) { if (a[i][j]==1&&(i==x||j==y||abs(x-i)==abs(y-j))) return 0; } } a[x][y... 阅读全文

posted @ 2012-10-09 18:57 为梦飞翔 阅读(184) 评论(0) 推荐(0)

2012年10月7日

查找某一范围内的重复数字

摘要: #include<iostream.h>#include<string.h>void main(){ unsigned char b[1000000/8+1]; memset(b,0,1000000/8+1); int x=1000000-2; b[x/8]|=(1<<(x%8)); int y=b[x/8]; cout<<y<<endl;} 阅读全文

posted @ 2012-10-07 22:57 为梦飞翔 阅读(224) 评论(0) 推荐(0)

2012年9月29日

组合以及可以重复的排列

摘要: #include<iostream.h>void fun(int m)//m的m次方,允许重复的全排列{ int *a=new int[m+1]; for(int i=0;i<=m;i++) a[i]=0; while(a[m]!=1) { for(int i=0;i<m;i++) cout<<a[i]<<" "; cout<<endl; for(int j=0;j<=m;j++) { a[j]+=1; if(a[j]>=m) a[j... 阅读全文

posted @ 2012-09-29 23:41 为梦飞翔 阅读(493) 评论(0) 推荐(0)

编程之美-1的个数统计

摘要: #include <iostream.h>#include <MATH.H>int fun(int N){ int num=0; int length=(int)log10(N)+1; for (int i=1;i<=length;i++) { num+=N/(int)pow(10,i)*(int)pow(10,i-1); int index=N/(int)pow(10,i-1)%10; switch(index) { case 0: ... 阅读全文

posted @ 2012-09-29 17:12 为梦飞翔 阅读(248) 评论(0) 推荐(0)

迷宫最短路径深度优先

摘要: #include <iostream.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <math.h>#include <stdio.h>typedef struct Point { int x; int y;}Point;/*typedef struct Stack{ Point Array[100]; int length;}Stack;*/void fun(int (*a)[10],int i,int j,int m,int& 阅读全文

posted @ 2012-09-29 16:11 为梦飞翔 阅读(1105) 评论(0) 推荐(0)

2012年9月14日

深度和广度查找

摘要: #include <iostream.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <math.h>void fun(int (*a)[5],int i,int j,int m){ if(i<0||j<0||i>=m||j>=m||a[i][j]!=1) return; a[i][j]=2; fun(a,i-1,j,m); fun(a,i+1,j,m); fun(a,i,j-1,m); fun(a,i,j+1,m);}type 阅读全文

posted @ 2012-09-14 21:20 为梦飞翔 阅读(291) 评论(0) 推荐(0)

2012年9月12日

N的M次方,N和M都是超级大数,的后六位求法

摘要: #include <iostream.h>#include <string.h>#include <stdlib.h>#include <math.h>void fun(const char *a,const char *b ,char *c){ int remainder=0; int length=strlen(a)>strlen(b)?strlen(a):strlen(b); int x=length; for (int i=strlen(a)-1,j=strlen(b)-1;i>=0||j>=0;i--,j--) { i 阅读全文

posted @ 2012-09-12 20:35 为梦飞翔 阅读(437) 评论(0) 推荐(0)

2012年9月9日

高精度加减法 1000阶乘求法

摘要: 1000的阶乘 2568位#include <iostream.h>#include <string.h>#include <stdlib.h>#include <math.h>void fun(const char *a,const char *b ,char *c){ int index; if (a[0]>'0'&&b[0]>'0')//两个正数相加 { index=0; } if (a[0]=='-'&&b[0]=='-')//两个 阅读全文

posted @ 2012-09-09 15:59 为梦飞翔 阅读(590) 评论(0) 推荐(0)

2012年9月8日

删除子串

摘要: #include <iostream.h>#include <string.h>void fun(char *a,char *b,char *c){ if (strlen(b)==0) { strcpy(c,a); return; } char *current=strstr(a,b); char *head=a; while (current!=NULL) { strncat(c,head,current-head); head=current+strlen(b); current... 阅读全文

posted @ 2012-09-08 22:05 为梦飞翔 阅读(238) 评论(0) 推荐(0)

上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 14 下一页

导航