面试题3

一、 填空题:

  1. 一些Linux命令,显示文件,拷贝,删除

      ls ,cp,rm

  2. do……while和while……do有什么区别?

先执行,后判断。 先判断后执行

  1. Linux系统下.ko文件是什么文件?.so文件是什么文件?

一个是内核模块文件,另一个是库文件。

  1. 二维数组AA [ 3 ][ 7 ]的另外一种表示方法:
*(*(AA+3)+7)
  1. 请写出下列代码的输出内容
  #include “stdio.h”

  main()

  {

  int a,b,c,d;

  a=10;

  b=a++;

  c=++a;

  d=10*a++;

  printf("b,c,d:%d%d%d",b,c,d);

  return 0;

  }

10,12,120

二、 编程题:

  1. 写出两个排序算法,并说明哪个好?

冒泡排序,直接插入排序

//冒泡排序

 void bubbleSort(int *a, int len)
 {
for(int i=len;i > 1;i--)
{
for(int j=2;j <= i;j++)
{
if(a[j-1]>a[j])
{
a[0]=a[j-1];
a[j-1] = a[j];
a[j] = a[0];
}
}
} 
 }
 void selectSort(int *a,int len)
 {
int k;
for(int i =1;i<=len;i++)
{
k = i;
for(int j=i+1;j<=len;j++)
{
if(a[j]<a[k])
{
k = j;
}
}
if(k != i)
{
a[0]=a[k];
a[k]=a[i];
a[i] = a[0];
}
}
 }

//选择排序

算法平均时间O(n^2),辅助空间O(1),选择排序稳定性差。

  1. 打开一个文件,并读取从第100字节开始的50字节数据。

#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
int fd;
char buffer[100]={'\0'};
if((fd=open("/etc/liu",O_RDWR,777))< 0)
{
printf("file is not existing\n");
}
else
{
printf("open file %d\n",fd);
}
lseek(fd,100,SEEK_SET);
read(fd,buffer,50);
printf("%s\n",buffer);
if((fd =close(fd))<0)
{
printf("close file failed\n");
}
return 0;
}
  1. 编写一个函数,输入一个的整型数字,可以选择按照8/10/16进制输出字符串。
#include<stdio.h>

#include<stdlib.h>

void convertBinString()

{

int i;

printf("the number you input\n");

int number;

scanf("%d",&number);

printf("convert to 8 binary String ,please input 0\n");

printf("convert to 10 binary String ,please input 1\n");

printf("convert to 16 binary String ,please input 2\n");

scanf("%d",&i);

switch(i)

{

case 0:

printf("The result %o",number);

break;

case 1:

printf("The result %d",number);

break;

printf("The result %x",number);

break;

default:

beak;

}

}

int main(void )

{

return 0;

}
  1. 如果有一个简单的helloworld项目目录如下:

  # tree helloworld

  helloworld

  |– file2.h

  |– file1.cpp

  |– file2.cpp

objs =file1.o file2.o

helloworld:$(objs)

gcc -o helloworld  $(objs)

$(objs):file2.h

file1.o:file1.cpp

file2.o:file2.cpp

clean:

rm -rf *.o helloworld

请编写一个Makefile文件。

三、 简答题:

ARM-linux启动分几部分,简述流程:

1.bootloader引导内核 2.内核启动 3加载文件系统 4启动应用程序。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值