上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 31 下一页
摘要: #include using namespace std;int a[30],n,used[40];int is_prime(int x){ for(int i=2;i>n) { memset(used,0,sizeof(used)) ; a[1]=1; used[1]... 阅读全文
posted @ 2014-08-04 10:57 2014acm 阅读(116) 评论(0) 推荐(0) 编辑
摘要: #include#includeusing namespace std;int main(){ string s; while(cin>>s) { int i,begin,end,total = s.size(),l = s.size(); for(i ... 阅读全文
posted @ 2014-08-03 21:27 2014acm 阅读(133) 评论(0) 推荐(0) 编辑
摘要: //使用数组queue[ ]存放结点队列void BFS( ) { head=0; tail=1; queue[head]=首结点的值; while (head<tail) //队列不空 { temp=tail; for (k=head; k<=ta... 阅读全文
posted @ 2014-08-03 21:14 2014acm 阅读(248) 评论(0) 推荐(0) 编辑
摘要: void DFS(int k) //处理第k步{ for (int i=1; iusing namespace std;int n,m, a[10];void DFS(int k){ for (int i=1; i>m>>n; DFS(0); return 0; ... 阅读全文
posted @ 2014-08-03 20:08 2014acm 阅读(169) 评论(0) 推荐(0) 编辑
摘要: #include #include int a[10];using namespace std;int main(){ memset(a,-1,sizeof(a)); for(int i=0;i#include int a[10];using namespace std;int main(){me... 阅读全文
posted @ 2014-08-03 19:24 2014acm 阅读(200) 评论(0) 推荐(0) 编辑
摘要: f() ……; 是逻辑判断语句,如果括号内逻辑值为真,则继续执行下一条语句,否则不执行 计算机默认以“0”代表逻辑假,以“非0值”代表逻辑真上述程序的意思就是不断从键盘向a赋值,直到赋给a的值为一个非0数 若a非0,则逻辑值为真,“!”表示取反,!a的逻辑值就为假,不执行下一条语句;从逻辑值的角度考... 阅读全文
posted @ 2014-08-03 18:56 2014acm 阅读(1294) 评论(0) 推荐(0) 编辑
摘要: #include#include#includeusing namespace std;int a[100],flag=1,b[10][10];int f(int k,int j){ for(int i=0;i#include#includeusing namespace std;int a[100... 阅读全文
posted @ 2014-08-03 18:05 2014acm 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 递归回溯代码#include using namespace std;int n,m, a[10];bool bz[3][10];void DFS(int k){ int i;if (k==n) { for ( i=0; i>n; DFS(0);return 0;}V... 阅读全文
posted @ 2014-08-03 16:38 2014acm 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 深度优先(DFS)模板1:void DFS(int k) //处理第k步{ if (k==n) //已经处理到第n步,到达目的状态 输出结果 else//处理第k步 for (int i=1; iusing namespace std;int n,m, a[10];void DFS(int k)... 阅读全文
posted @ 2014-08-03 14:42 2014acm 阅读(279) 评论(0) 推荐(1) 编辑
摘要: Description会下国际象棋的人都很清楚:皇后可以在横、竖、斜线上不限步数地吃掉其他棋子。如何将8个皇后放在棋盘上(有8 * 8个方格),使它们谁也不能被吃掉!这就是著名的八皇后问题。对于某个满足要求的8皇后的摆放方法,定义一个皇后串a与之对应,即a=b1b2...b8,其中bi为相应摆法中第... 阅读全文
posted @ 2014-08-03 13:02 2014acm 阅读(148) 评论(0) 推荐(0) 编辑
上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 31 下一页