07 2013 档案
摘要:题目:http://poj.org/problem?id=1573题意:已知坐标系大小,和初始的最上面的位置,根据命令求是否能出去,或者一直循环这就是我建的系,画的有点难看哈! 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std;10 char map[500][500];11 int vis[500][500];12 13 int dx[5]={0,0,-1,1};//分别代表N,S,W,E14 int dy[5]={1,-.
阅读全文
摘要:题目:http://poj.org/problem?id=2632题意:已知仓库大小,告诉机器人的起始位置和方向,告诉m条指令,求按指令会不会撞墙或撞机器人。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 int map[110][110]; 9 int dx[5]={0,1,0,-1};10 int dy[5]={1,0,-1,0};11 struct node12 {13 int x,y,d;//d与dx,dy数组记录方向14 }rob[1000];15 int...
阅读全文
摘要:一个水题,全是小错误,整了一下午。题目:http://poj.org/problem?id=1068题意:给出一组括号: (((()()())))P是”)“前面有几个“(”: 4 5 6 6 6 6S是“)”前面第几个“(”是对应的: 1 1 1 4 5 6让你根据给出的P求对应的S 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 int main() 9 {10 int n,i,t,a[1500],b[1500]...
阅读全文
摘要:题目:http://poj.org/problem?id=3295题意:p,q,r,s,t,是五个二进制数。K,A,N,C,E,是五个运算符。K:&&A:||N:!C:(!w)||xE:w==x题意是让求如果对于五个数的所有情况一个式子总是恒为1,那么这个式子就是tautology。输出tautology。否则输出not。5个数,最多有2^5种情况。判断式子是不是恒为1,只需要从后往前判断即可。这题好长时间没看懂,代码也是看网上大神的 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace
阅读全文
摘要:题目:http://poj.org/problem?id=2506题解:f[n]=f[n-2]*2+f[n-1],主要是大数的相加;以前做过了的 1 #include 2 #include 3 4 int ans[251][260];//ans数组的第一个下标表示瓷砖数目,第二个表示对应下的方法数 5 //数组是倒序存储 的 6 int main() 7 { 8 int n, i, j, count, b, p; 9 while (scanf("%d", &n) != EOF)10 {11 memset(ans, 0, sizeof(ans));12 ...
阅读全文
摘要:用搜索(bfs,dfs)做了半天,都超时,原来是dp;参考博客:http://www.cnblogs.com/liuzezhuang/archive/2012/07/29/2613820.html 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 int map[30][30],b[30][30]; 9 int main()10 {11 int h,w,i,j;12 cin>>h>>w;13 14 for(i=1; i>map[i][j];17 ...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #define N 36 8 int place[N]; 9 int x,y,price,count;//现在的会员人数;全部的会员人数;停车单价;已用车位数; 10 double sum;//盈利总额 11 12 void menu(); 13 void parking(); 14 void take(); 15 void amoney(); 16 void show(); 17 void profit(...
阅读全文
摘要:老师写的,我改了一下 1 #include 2 #include 3 #include 4 #define N 28 5 int count=0; 6 void menu(); 7 void insert(); 8 void show(); 9 void del(); 10 void password(int id); 11 int box[N]={0}; 12 int main() 13 { 14 int x; 15 while(1) 16 { 17 menu(); 18 scanf("%d",&x); 19 ...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 void menu(); 6 void clos(); 7 void cancle(); 8 void quit(); 9 10 int main()11 {12 while(1)13 {14 menu();15 }16 }17 18 void menu()19 {20 int x;21 system("cls");22 printf("1---------关机\n");23 printf("2---------取消\n");24...
阅读全文
摘要:实训老师讲的,又学到了贴下代码 1 #include 2 #include 3 #include 4 int x=15; 5 6 int main() 7 { 8 FILE *fp; 9 char name[50][20];10 int i,flag;11 fp=fopen("D:\\fan.txt","r");//首先在D盘建一个fan.txt,里面要有字符串,以回车或空格为间隔12 for(i=0; i 2 #include 3 #include 4 int x=10; 5 6 int main() 7 { 8 FILE *fp; 9 ...
阅读全文
摘要:实训的题,今天又学到了很多…… 1 #include 2 #include 3 #include 4 #include 5 int main() 6 { 7 int a,b,sum=0; 8 int x=5; 9 10 while(x--)11 {12 //游戏规则13 printf("┌───────┐\n");14 printf("│0--石头 │\n");15 printf("│1--剪刀 │\n");16 printf("│2--布 │...
阅读全文
摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=1874spfa 模板 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int INF=1q;10 11 struct node12 {13 int u,v,w,next;14 } edge[1100];15 16 void add(int u,int v,int w)17 {18 edge[cnt].u=u;19 edge[cnt].v=v;20 edge[cnt]...
阅读全文
摘要:今天发现寒假学的图论基础还挺有用,今天贴下代码邻接矩阵: 1 #include 2 #include 3 4 int map[100][100]; 5 6 void init() 7 { 8 memset(map,0,sizeof(map)); 9 }10 11 void add(int...
阅读全文
摘要:题目:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2128&cid=1184 1 #include 2 #include 3 #include 4 struct tree 5 { 6 int data; 7 struct tree *l,*r; 8 }; 9 int x;10 11 void build(struct tree *root,int a)12 {13 struct tree *p;14 p=(struct tree *)malloc(sizeof(struct tree));15 if...
阅读全文
摘要:题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1291以前的一个题,贴下代码; 1 #include 2 #include 3 char ans[100]; 4 5 void build(int n, char *s1, char *s2, char *s) 6 { 7 if(n <= 0) return; 8 int p = strchr(s2, s1[0])-s2; 9 build(p, s1+1, s2, s);10 build(n-p-1, s1+p...
阅读全文
摘要:题目:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2136&cid=1184 自己重新写的: 下面的代码如果建树 不想要返回值的话,也可以这些写 void build(tree *&p) { },这样用引用可以自动 改变L和R的指向。 如果不加
阅读全文
摘要:c++ sort :http://www.16kan.com/post/997260.html http://wenku.baidu.com/view/e064166daf1ffc4ffe47ac67.html 假设自己定义了一个结构体 node struct node { int a; int b
阅读全文

浙公网安备 33010602011771号