coder_new

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2016年6月2日

摘要: 状态DP 阅读全文
posted @ 2016-06-02 13:49 coder_new 阅读(187) 评论(0) 推荐(0) 编辑

2014年6月25日

摘要: 有四个线程1、2、3、4。线程1的功能就是输出1,线程2的功能就是输出2,以此类推.........现在有四个文件ABCD。初始都为空。现要让四个文件呈如下格式:A:1 2 3 4 1 2....B:2 3 4 1 2 3....C:3 4 1 2 3 4....D:4 1 2 3 4 1....题... 阅读全文
posted @ 2014-06-25 15:26 coder_new 阅读(215) 评论(0) 推荐(0) 编辑

2014年3月13日

摘要: //假设这有两个分别由字母组成的字符串A另外字符串B,字符串B的字母数较字符串A少一些。//什么方法能最快地查出字符串B所有字母是不是都在字符串A里?//也就是说判断字符串B是不是字符串A的真子集(为了简化,姑且认为两个集合都不是空集,即字符串都不为空。)。为了简单起见,我们规定输入的字符串只包含大写英文字母。//实现函数bool compare(string &A,string &B)//int 32位,使用一个整数来hash#include using namespace std;bool compare(string &a,string &b){ int 阅读全文
posted @ 2014-03-13 16:46 coder_new 阅读(178) 评论(0) 推荐(0) 编辑

摘要: //左旋转字符串#include using namespace std;//一位位移动void shiftLeftOne(char *str){ int len=strlen(str); char temp=str[0]; for(int i=1;i<len;i++) { str[i-1]=str[i]; } str[len-1]=temp;}char *shiftLeft(char *str,int n){ int len=strlen(str); n=n%len; while(n--) { shiftLeftOn... 阅读全文
posted @ 2014-03-13 15:48 coder_new 阅读(186) 评论(0) 推荐(0) 编辑

2014年3月6日

摘要: [Input example]2710 30 30 10 20 0 30 30 50 10 40 50 60 30208 -2 39 38 -22 -5 0 64 70 -8 -7 -30 40 -21 68 12 30 46 58 45 -24 40 8 1 16 66 41 58 37 25 20 -22 43 38 -12 14 29 40 -9 -4[Output example]1500.006863.50#include #include typedef struct _SPOT_{ int x; int y;} Spot;int N;Spot data[105];in... 阅读全文
posted @ 2014-03-06 16:13 coder_new 阅读(291) 评论(0) 推荐(0) 编辑

2014年3月4日

摘要: [Input Example]2101 2 3 4 5 6 7 8 9 91027 22 15 30 29 12 20 13 6 10[Output Example]10 9 8 7 6 5 4 3 1 13 4 6 1 2 8 5 7 10 91.排序#include #include #include int N;typedef struct _SIS SIS;struct _SIS { int pos; int val;};SIS Sis[300005];int order[300005];int comp(const void *a, const void *b){ ... 阅读全文
posted @ 2014-03-04 10:26 coder_new 阅读(240) 评论(0) 推荐(0) 编辑

2014年3月1日

摘要: [Input Example]241 1 5 5 5 7 10 1015-15 41 50 47 10 54 71 -57 35 -64 27 -70 -88 77 48 83 8 90 69 -96 29 -3 89 -9 -50 19 6 26 66 32[Output Example]2 35 61.分治#include #include #include #define N 10000#define MAX 0x7FFFFFFFint num;typedef struct _STAR STAR;struct _STAR{ int x; int y; int index... 阅读全文
posted @ 2014-03-01 10:12 coder_new 阅读(862) 评论(0) 推荐(0) 编辑

2014年2月8日

摘要: 单向链表typedef struct _LINKED_NODE LINKED_NODE;struct _LINKED_NODE { int data; LINKED_NODE *next;};链表节点建立LINKED_NODE *createLinkedNode(int nValue){ LINKED_NODE *pNode=NULL; pNode=(LINKED_NODE *)malloc(sizeof(LINKED_NODE)); if(pNode==NULL) return NULL; pNode->data=nValue; pNode->nex... 阅读全文
posted @ 2014-02-08 10:56 coder_new 阅读(275) 评论(0) 推荐(0) 编辑

摘要: #include #include #define MAX 10int comMatrix[MAX][MAX];char comstr[MAX];char *commonString(char string1[], char string2[]){ int len1=0,len2=0; int flag=0; int max=0; int i, j; while(string1[len1]!='\0') len1++; while(string2[len2]!='\0') len2++; for(i=0;i0&&j>0&&c 阅读全文
posted @ 2014-02-08 10:50 coder_new 阅读(187) 评论(0) 推荐(0) 编辑

摘要: 冒泡排序:稳定,时间复杂度O(n2),空间复杂度O(1)//bubblevoid bubblesort(int *a, int n){ int hig=n-1; int i; while(hig) { for(i=0;ia[i+1]) swap(&a[i],&a[i+1]); } hig--; }}鸡尾酒排序:稳定,时间复杂度O(n2),空间复杂度O(1)。冒泡排序的变形。//cocktailvoid cocktailsort(int *a ,int n){ int low=0,hig=n-1; int i; ... 阅读全文
posted @ 2014-02-08 10:06 coder_new 阅读(194) 评论(0) 推荐(0) 编辑