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)

导航