摘要: 1 #include<stdio.h> 2 #include<string.h> 3 4 int main() 5 { 6 int i, ncases, len, c[102]; 7 char a[100], b[100]; 8 9 while(scanf("%d", &ncases) != EOF)10 {11 12 while(ncases--)13 {14 memset(c,0,sizeof(c)); 15 ... 阅读全文
posted @ 2011-09-06 21:59 zhongya 阅读(202) 评论(0) 推荐(0) 编辑
摘要: 注:网上搜的第一篇 1001 这个就不用说了吧1002 简单的大数1003 DP经典问题,最大连续子段和1004 简单题1005 找规律(循环点)1006 感觉有点BT的题,我到现在还没过1007 经典问题,最近点对问题,用分治1008 简单题1009 贪心1010 搜索题,剪枝很关键1011 1012 简单题1013 简单题(有个小陷阱)1014 简单题1015 可以看作搜索题吧1016 经典的搜索1017 简单数学题1018 简单数学题1019 简单数学题1020 简单的字符串处理1021 找规律的数学题1022 数据结构的题(栈的应用)1023 特殊的数(Catalan Numbe... 阅读全文
posted @ 2011-09-06 16:41 zhongya 阅读(4874) 评论(1) 推荐(3) 编辑
摘要: ZOJ题目分类初学者题:1001 1037 1048 1049 1051 1067 1115 1151 1201 1205 1216 1240 1241 1242 1251 1292 1331 1334 1337 1338 1350 1365 1382 1383 1394 1402 1405 1414 1494 1514 1622 1715 1730 1755 1760 1763 1796 1813 1879 1889 1904 1915 1949 2001 2022 2099 2104 2108 2172 2176 2201 2208 2321 2345 2351 2376 2388 240 阅读全文
posted @ 2011-09-06 16:40 zhongya 阅读(251) 评论(0) 推荐(1) 编辑
摘要: 1 大体思路是这样,由于括号必定是偶数,每一个P前面都有P个左括号 2 W就是与左括号到与它匹配的右括号之间右括号的个数。 3 可设立一个数组用W[21]于存放标记,初始化为0,从P处开始向前当有 4 匹配的右括号时就记录下来W[i]=1,最后P-i+1就是所要求的值。 5 6 #include <stdio.h> 7 #include <string.h> 8 9 int main()10 { 11 int i, n, ncases;12 int w[21], k, p;13 14 scanf("%d", &ncases); 15 whil 阅读全文
posted @ 2011-09-05 22:09 zhongya 阅读(223) 评论(0) 推荐(0) 编辑
摘要: 1 #include <stdio.h> 2 #include <string.h> 3 #define N 100001 4 5 char s[N+10];//字符数组开大一点以免发生段错误 6 struct 7 { 8 int data[N+10]; 9 int top;10 }st; //建立一个数值栈用于存放字符的下标。 11 12 int match(int m,int n)//判断是否匹配13 {14 if (s[st.data[m]]=='('&& s[n]==')')15 return 1;16 if (s 阅读全文
posted @ 2011-09-05 21:17 zhongya 阅读(250) 评论(0) 推荐(0) 编辑
摘要: 表达式的求解的关键是将其转换成逆波兰表达式(即后缀表达式,如1+2*3它的逆波兰表达式为123*+),在后缀表达式中已经考虑了运算符的优先级,没有括号,只有操作数和运算符。算术表达式转换成后缀表达式方法如下:依次从键盘输入表达式的字符ch,对于每个ch:(1)若ch为数字则直接将其放入后缀数组exp中并以#号标记数值串结束。(2)若ch为"(",则直接将其压入字符栈op中。(3)若ch为")",则将栈中"("以前的字符依次全部删除并将其放入后缀数组exp中,然后再将字符ch放入字符栈op中。(4)若ch为"+".& 阅读全文
posted @ 2011-09-02 15:26 zhongya 阅读(2513) 评论(0) 推荐(1) 编辑
摘要: 1#include <stdio.h> 2 #include <windows.h> 3 #include <conio.h> 4 #include <math.h> 5 #include <stdlib.h> 6 #include <string.h> 7 #define N 200 8 9 void trans(char str[],char exp[])//这是求解的关键,将算术表达式转换成逆波兰表达式。 10 { 11 struct 12 { 13 char data[N]; 14 int top; //栈顶指.. 阅读全文
posted @ 2011-09-02 14:23 zhongya 阅读(725) 评论(0) 推荐(1) 编辑
摘要: 1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<queue> 5 6 using namespace std; 7 8 queue<int>q; 9 int main() 10 { 11 int a, x, b, y; 12 int visit[9][9]; 13 char c1, c2, r1, r2; 14 15 while(cin>>c1>>r1>>c2>>r2) 16 { 17 mems 阅读全文
posted @ 2011-08-29 22:47 zhongya 阅读(356) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 #include<iostream> 5 6 using namespace std; 7 8 char map[30][30]; 9 int vis[30]; 10 int dir[4][2] = {1,0,-1,0,0,-1,0,1}; //搜索的四个方向,这里用数组表示,为了下面表示方便11 int ans, row, col, loc; //loc表示搜索的深度。12 13 int Inmap(int nr,in 阅读全文
posted @ 2011-08-26 17:09 zhongya 阅读(756) 评论(0) 推荐(0) 编辑
摘要: 1 先灌满A和先灌满B效果一样。 2 #include<stdio.h> 3 4 int main() 5 { 6 int ca, cb, n, i; 7 while(scanf("%d%d%d",&ca,&cb,&n) != EOF) 8 { 9 if(ca==1)//做一个判断,为1时直接灌n次即可10 {11 for(i=1; i<=n; i++)12 {13 printf("fill A\n");14 printf(... 阅读全文
posted @ 2011-08-25 17:03 zhongya 阅读(197) 评论(0) 推荐(0) 编辑