Chinaunix首页 | 论坛 | 博客
  • 博客访问: 179983
  • 博文数量: 33
  • 博客积分: 2047
  • 博客等级: 大尉
  • 技术积分: 333
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-21 19:35
文章分类

全部博文(33)

文章存档

2011年(1)

2010年(21)

2009年(11)

分类: C/C++

2009-12-17 21:31:53

Samsung Intern (50minutes)

1. 求循环链表中元素的个数 【10’】
struct ListNode
{
    struct ListNode *pNext;
    char   *data;
};
struct CircularList
{
    struct ListNode *pListHeader;
};

/* Input: pList--要计数的循环链表指针
   Return: the number of the CircularList
*/
unsigned int GetNodesNum(struct CircularList *pList)
{
}

2. 二分查找BinarySearch【20‘】
/* Input: pIArray: 已排好序的序列
           iLength: 数组元素个数
           iTarget: 要查找的元素
   Return: 返回iTarget在数组中的索引;如果数组中不存在iTarget返回iLength
*/
unsigned int BinarySearch(int *pIArray, unsigned int iLength, int iTarget)
{
}

3. F Mod M, F,M都是unsigned int类型,要求使用固定的内存,也就是说内存容量稳定,不随数的大小而出现改变?可能是要 写大数快速求模的函数。
求F Mod M的值【20’】
/*
   Return: 要返回数F Mod 数M的值f mod m
*/
unsigned int Mod(unsigned int f, unsigned int m)
{
}

4. 求数字序列中最大的数,序列a0,a1,...,an满足:
   a[0] = 0
   a[1] = 1
   a[2i] = a[i]
   a[2i+1] = a[i] + a[i+1]
   Find the largest number of the sequence.【20‘】
/* Input: pArray是指向序列的指针
          maxIndex是序列的最大索引值
   Return: 返回最大值的索引值
*/
unsigned int GetLargest(int *pArray, int maxIndex)
{
}

5. 求一个串中匹配'?' '*'的字符串的个数【30’】
   '*'匹配0个或多个字符串; '?'匹配一个字符;不考虑转义字符。
/* Input: pString是要匹配的字符串; pPattern是模式例如"hj*df","abc???def";
   Return: 返回pString中能够匹配pPattern模式的子字符串的个数;
*/
unsigned int GetNum(const char *pString, const char *pPattern)
{
}

欢迎大家讨论第三 四 五题!




阅读(664) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~