当前位置 博文首页 > swfa1的专栏:百度北京站2014研发笔试
1、OSI七层模型
2物理层
3数据链路层
4网络层
5传输层
6会话层
7表示层
8应用层
2、进程间数据共享的方式三种
文件映射
共享内存
信号
匿名管道
命名管道
邮件槽
剪贴板
3、TCP/UDP区别
4、打印数组的所有组合
#include <stdio.h>
int n = 0;
void swap(int *a, int *b)
{
int m;
m = *a;
*a = *b;
*b = m;
}
void perm(int list[], int k, int m)
{
int i;
if(k > m)
{
for(i = 0; i <= m; i++)
printf("%d ", list[i]);
printf(" ");
n++;
}
else
{
for(i = k; i <= m; i++)
{
swap(&list[k], &list[i]);
perm(list, k + 1, m);
swap(&list[k], &list[i]);
}
}
}
int main()
{
int list[] = {1, 2, 3, 4, 5};
perm(list, 0, 4);
printf("total:%d ", n);
return 0;
}
二进制
首先,把数组每一个元素用一个二进位表示,例如:
A?B?C?D?E
1?1?1?1?1?--->?于是它最多有11111(二进制)种不重复组合(即31种)(不考虑顺序--按楼主要求)
于是,只要检查从1到31这些数字的二进位哪些是二进制值1,就可以得出组合了。(位值为1的元素选取,位值为0的元素弃之)
(转自网络)
5、二叉树的面积
深度优先搜索,广度优先搜索的实现
#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
#define TRUE 1
#define FLASE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2
typedef int Status;
typedef int TElemType;
typedef struct BiTNode
{
TElemType data;
struct BiTNode *lchild,*rchild;
} BiTNode,*BiTree;
Status CreateBiTree(BiTree &T)
{
TElemType e;
scanf("%d",&e);
if(e==0) T=NULL;
else
{
T=(BiTree)malloc(sizeof(BiTNode));
if(!T)
exit(OVERFLOW);
T->data =e;
CreateBiTree(T->lchild );
CreateBiTree(T->rchild );
}
return OK;
}
int max(int a[])
{
int max,i;
max=a[0];
for(i=1;i<20;i++)
{
if(max<a[i])
max=a[i];
}
return max;
}
int BiTreeWidth (BiTree T)
{
if(T==NULL)
return 0;
else
{
static int a[20]={0};
static int i=0;
a[i]++;
i++;
BiTreeWidth (T->lchild );
if(T->lchild ==NULL)
i--;
BiTreeWidth (T->rchild );
if(T->rchild ==NULL)
i--;
return max(a);
}
}
另附: