曾经的NOKIA面试题

“知不知,上;不知知,病。圣人不病,以其病病。夫唯病病,是以不病。”

1   find out the wrong definition of array.

      A   int A[]             B   int A[]={1,2,3,4,5};

      C   int A[10]={0}        D   int A[10]

2  give description between big endian and little endian (字节存储次序)And write a macro to convert a 16bit integer to big endian.

/* Note:Your choice is C IDE */

#include "stdio.h"

#define MAX(a,b) ((a)>(b))?(a):(b)

#define CONVERT_TO_BIGENDIAN(x) {char temp=(char)(x&0x00FF);/

                                     *((char*)(&x))=(char)((x&0xFF00)>>8);/

                                *((char*)(&x)+1)=temp;}

main()

{

    int A[]={1,2,3,4,5};

    int B[10]={0};

    int C[10];

    int a1=0x1234;

    printf("%d/n",sizeof(int));/*2*/

    printf("%x/n",a1);/*1234*/

    printf("%x/n",*(char*)(&a1));/*34*/

    printf("%x/n",*((char*)(&a1)+1));/*12*/

    printf("%x/n",(char)((a1&0xFF00)>>8));/*34*/

    printf("%x/n",(char)(a1&0x00FF));/*34*/

    CONVERT_TO_BIGENDIAN(a1)/*3434*/

    printf("%x",a1);

    return;

}

注:

A N S I标准说明了五个预定义的宏名。它们是:

_ L I N E _ (两个下划线),对应%d

_ F I L E _    对应%s

_ D A T E _   对应%s

_ T I M E _   对应%s

_ S T D C _

使用宏跟踪调试

3  tell the literal meaning of words below.

      static

C : static func;static global variant ;local static variant:控制存储方式,控制可见性和链接类型,

C++ :static member func and static member variant:

      union: 多个成员变量的集合,但同一时间只存储一个成员变量,空间大小为最大的一个成员占有的空间

      const:

C : 限定一个变量不容许被改变的qualifier,

C++ :cosnt 可修饰对象/成员函数/参数/返回值,一个左结合的类型修饰符

      void *:无类型指针,可以指向任何类型的数据,无需强制类型转换地赋给其它类型的指针

void真正发挥的作用在于:void不能代表一个真实的变量,类似面向对象中的抽象基类

  (1) 对函数返回的限定;如果函数没有返回值,那么应声明为void类型(在C语言中,凡不加返回值类型限定的函数,就会被编译器作为返回整型值处理

  (2) 对函数参数的限定。如果函数无参数,那么应声明其参数为void.如果函数的参数可以是任意类型指针,那么应声明其参数为void*

      enum:

enum 枚举名{ 枚举值表 }; 同结构和联合一样,即先定义后说明,同时定义说明或直接说明.
枚举值是常量,不是变量。不能在程序中用赋值语句再对它赋值.枚举元素本身由系统定义了一个表示序号的数值,从0开始顺序定义为0,1,2…。

     extern: 置于变量或者函数前,以标示变量或者函数的定义在别的文件中,提示编译器遇到此变量和函数时在其他模块中寻找其定义。

4  correct

char fun1(char* s)

{ char* temp=s; char ret=temp[1]; return ret;};

   char * s1=”abcd”;

   char (*pFunc)(char*)=fun1;

printf(“%c/n”,pFunc(s1)); //b

5  a single list, display the Kth data from the last list node . the less loop the better.

6  display the data of a binary tree ,from the top to bottom ,same height from left to right.

7  Program to define the rect stuct ,and write a func to give the merged rect.

 

8 you know the string func of strcmp , write stricmp to ignore the case comparison. (ascii A:65, a:97)

9 design UI interface for fetch the data module , the data module get the data from the device which get data from outside regularly. The data module will provide interface for upper component ,and obtain the first 8 biggest data .

注册回调实现。

插入法:初始化循环单链表,分配8个节点,遍历插入。

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值