上一页 1 ··· 8 9 10 11 12 13 14 下一页
摘要: #include<stdio.h>#include<stdlib.h>#include<string.h>#define OK 1#define ERROR 0char sz[8]=" +-*/";int list[25][5],map[5][5],visit[5],t,pp[5];char z[400];double two(double a,int f,double b){ switch(f) { case 1: { return a+b; break; } case 2: { ... 阅读全文
posted @ 2013-03-24 10:42 萧凡客 阅读(175) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> #include <stdlib.h> #include <string.h> /*下面定义结点的类型*/ #define Min(a,b) ((a>b)?b:a) //宏定义的操作符Min作用 取最小值; const int MAX=1010; //解答树的结点最多 typedef struct Node { int v[3];//三个杯子的剩余水量; int fa;//第一次访问到这个结点是的前一个结点的下标; //通过下标可以随机访问真不错; int last_op;//记录从上个结点到这个结点的变化方式 . 阅读全文
posted @ 2013-03-24 10:29 萧凡客 阅读(221) 评论(0) 推荐(0) 编辑
摘要: 本文列出了24条能让你的代码编写过程更为轻松高效的建议。也许您还是JavaScript初学者,刚刚写完自己的Hello World,那这里有很多对您的工作将十分有用的小贴士;也许有些技巧您已经知道,那就试试快速浏览一下,看能不能发现一点新东西吧!注:本文多次用到Firebug的console对象,请参考Firebug Console API 。关于firebug的更详细介绍,请猛击这里。1. 用 === 代替 ==JavaScript里有两种不同的相等运算符:===|!== 和==|!=。相比之下,前者更值得推荐。请尽量使用前者。 引用: “如果两个比较对象有着同样的类型和值,===返回tru 阅读全文
posted @ 2013-03-24 10:20 萧凡客 阅读(246) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 5 6 int a[10]={1,9,5,6,7,4,1,5,8,3}; 7 typedef struct 8 { 9 double x;10 double y;11 }b;12 //一维数组的排序(整形)13 int comp(const void *p,const void *q)14 {15 return *(int *)p>*(int *)q ? 1:-1;//从小到大16 17 /* return -(*(int . 阅读全文
posted @ 2012-12-15 09:35 萧凡客 阅读(224) 评论(0) 推荐(0) 编辑
摘要: (1)当n=1时,不论m的值为多少(m>0),只有一种划分即{1}; (2) 当m=1时,不论n的值为多少,只有一种划分即n个1,{1,1,1,...,1}; (3) 当n=m时,根据划分中是否包含n,可以分为两种情况: (a). 划分中包含n的情况,只有一个即{n}; (b). 划分中不包含n的情况,这时划分中最大的数字也一定比n小,即n的所有(n-1)划分。 因此 f(n,n) =1 + f(n,n-1); (4) 当n<m时,由于划分中不可能出现负数,因此就相当于f(n,n); (5) 但n>m时,根据划分中是否包含最大值m,可以分为两种情况: (a). 划分中包含m的 阅读全文
posted @ 2012-12-13 22:19 萧凡客 阅读(226) 评论(0) 推荐(0) 编辑
摘要: 1 /*N皇后问题*/ 2 #include<stdio.h> 3 #include<string.h> 4 int a[20][20];//N皇后矩阵 5 int v[3][20];//v[0][i]表示列是否冲突;v[1][i]表示副对角线是否冲突; v[2][i]表示正对角线是否冲突 6 int n;//N皇后 7 int c[1000][20];//存放条件成立的结果 8 int num; 9 10 11 void fun(int cur)12 {13 int i;14 if(cur==n)15 {16 num++;17 ret... 阅读全文
posted @ 2012-12-13 20:42 萧凡客 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 1 /*#include<stdio.h> 2 #include<string.h> 3 4 int cur; 5 int a[20]; 6 7 void fun(int n)//不重复递归,即0,1 递归 8 { 9 int i;10 if(n==cur)11 {12 for(i=0;i<n;i++)13 printf("%d",a[i]);14 printf("\n");15 return;16 }17 a[n]=0;18 fun(n+1);19 20 a[... 阅读全文
posted @ 2012-12-13 12:26 萧凡客 阅读(158) 评论(0) 推荐(0) 编辑
摘要: sscanf函数sscanf(str+start,"%d%n",&v,&n);2011-05-19 20:56:00|分类:杭电acm|字号订阅 sscanf() - 从一个字符串中读进与指定格式相符的数据.函数原型: Int sscanf( const char *, const char *, ...);int scanf( const char *, ...);头文件: #include<stdio.h>说明: sscanf与scanf类似,都是用于输入的,只是后者以键盘(stdin)为输入源,前者以固定字符串为输入源。 第一个参数可以是一 阅读全文
posted @ 2012-12-13 10:16 萧凡客 阅读(255) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<string.h> 3 int a[18]; 4 int v[18]={0}; 5 int t[33]={0}; 6 int N; 7 8 void init() 9 {10 int i,j;11 for(i=2;i<33;i++) 12 if(!t[i])13 for(j=2*i;j<33;j+=i)14 t[j]=1;15 }16 17 void fun1(int n) //方法一18 {19 int i;20 if(n==N && ! ... 阅读全文
posted @ 2012-12-05 17:22 萧凡客 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<string.h> 3 int a[10],m,n; 4 5 //取数算法 6 7 8 /*1、从m中选出n个全排列,从大到小,不允许重复 9 10 3 2 输入 11 12 32 13 31 14 21 15 16 */ 17 void fun1(int m,int n) 18 { 19 int i,j; 20 for(i=m;i>0;i--) 21 { 22 a[n]=i; 23 if(n>1) 24 fun1(i... 阅读全文
posted @ 2012-11-27 15:05 萧凡客 阅读(340) 评论(0) 推荐(0) 编辑
上一页 1 ··· 8 9 10 11 12 13 14 下一页