Quantcast
Channel: 珍珠米一盘
Browsing latest articles
Browse All 10 View Live

Image may be NSFW.
Clik here to view.

动态规划典型:一卡通大冒险

问题描述: 因为长期钻研算法,无暇考虑个人问题,北航ACM/ICPC训练小组的帅哥们大部分都是单身。  某天,他们在机房商议一个绝妙的计划“一卡通大冒险”。这个计划是由Wash最先提出的,计划的内容是,把自己的联系方式写在校园一卡通的背面,然后故意将自己的卡“遗失”在某处(如水房,TD,食堂,主M……)他们希望能有MM看到他们“遗失”卡,能主动跟他们联系,这样就有机会请MM吃饭了。...

View Article



Image may be NSFW.
Clik here to view.

不要混用 strlen() 和 sizeof(), char *str 和 char str[]

摸索了一下UNP..做了一个小例子。。出现了一个小问题。。 服务器发送消息代码   //send info to client  //char* welmsg = (char*)malloc(30);   char* welmsg = "Welcome to my server!\n";  // char welmsg[]="Welcome to my server!\n";...

View Article

Image may be NSFW.
Clik here to view.

《算法导论》中堆排序的C语言实现

#include <stdio.h> #include <stdlib.h> #include <string.h> void Exchange(int &a, int &b) //交换两个数组元素 { int temp = b; b = a; a = temp; } void PrintArray(int* A, int heapsize)...

View Article

Image may be NSFW.
Clik here to view.

典型动态规划:求最长公共子序列的长度(LCS)

求最长公共子序列的长度 给定两个字符串,要求统计两个字符串的最长公共子序列的长度。 要求:尽量节省空间。 代码: #include <stdio.h> #include <string.h>   //author: Esyrt_Z  //data : 2011/06/22    int LcsLength(char* X, char* Y, int lenx, int...

View Article

Image may be NSFW.
Clik here to view.

PHP传JSON或者一些复杂数据给javascript处理的一系列问题。

最近在玩Sina APP Engine 在处理服务器返回微博的JSON数据时碰到不少问题,总结记录一些吧。 PHP部分 <?php ...... $ms  = $c->user_timeline(1,20); // 这是新浪微博返回用户所发微博数据的接口,默认返回的是JSON结构...

View Article


Image may be NSFW.
Clik here to view.

ADOBE笔试出的小学奥数题

2012 ADOBE实习生招聘最后一题: Tommy and other 8 classmates were in a math class. Teacher prepared 9 hats with a 2-digit number printed on each hat and the 9 numbers differ from each other. Then the teacher gave...

View Article

Image may be NSFW.
Clik here to view.

给一个字符串和一个字符集,求该字符串包含字符集的子串

给一个字符串和一个字符集,求该字符串包含字符集的子串 给出一个字符串,及一个字符集,求该字符串包含所有字符集的最短子串...

View Article

Image may be NSFW.
Clik here to view.

百度实习生笔试题 数组的前半段后半段分别已有序,对整个数组就地排序

//数组的前半段后半段分别已有序,假定都为升序,对整个数组排序,空间复杂度O(1) //当时在纸上写的时候忘记了一个条件,回来以后上机调试发现问题,及时的改正总结了。 #define N 10 void SortArray(int arr[], int size) { int slen; int str1bin, str2bin, strend; int temp; slen = size; int...

View Article


Image may be NSFW.
Clik here to view.

字符串全排列无重复的递归实现

经典递归应用 全排列就是从第一个字符起每个字符都分别与其后的字符交换,当然这里没有考虑去除重复的情况。 去除重复就是要在交换之前需要判断交换的字符的后面是否有重复的字符。 例如,字符串abb,当start指向a,p指向第一个b的时候,由于在该指针区间内没有只有唯一的b,所以需要交换a与b。但当start指向a,p指向第二个b的时候,由于在当前指针区间内这个b是与前面那个b重复的,所以不需要交换。...

View Article


Image may be NSFW.
Clik here to view.

获取IPv6前缀地址的方法

最近要改造一个系统使其支持IPv6,碰到一个问题,需要根据其前缀编码获取IPv6地址的前缀。 由于IPv6地址是128位,在Linux中使用 struct in6_addr   {     union       {  uint8_t u6_addr8[16];  uint16_t u6_addr16[8];  uint32_t u6_addr32[4];       } in6_u;...

View Article
Browsing latest articles
Browse All 10 View Live




Latest Images