阿尔卡特朗讯笔试题

时间:2020-11-23 10:31:34 笔试题目 我要投稿

阿尔卡特朗讯笔试题

 1. 如何打印出当前源文件的文件名以及源文件的当前行号?

阿尔卡特朗讯笔试题

 
通常使用的就是__FILE__, __LINE__,在调试函数中利用“%s”,”%ld”,打印就好了。

2. main主函数执行完毕后,是否可能会再执行一段代码,给出说明?
crt会执行另一些代码,进行处理工作。
如果你需要加入一段在main退出后执行的`代码,可以使用atexit()函数,注册一个函数。
语法:
#include <stdlib.h>
int atexit(void (*function”)(void));
#include <stdlib.h>
#include <stdio.h>

void fn1( void ), fn2( void ), fn3( void ), fn4( void );

int main( void )
{
atexit( fn1 );
atexit( fn2 );
atexit( fn3 );
atexit( fn4 );
printf( “This is executed first.\n” );
}

void fn1()
{
printf( “next.\n” );
}

void fn2()
{
printf( “executed ” );
}

void fn3()
{
printf( “is ” );
}

void fn4()
{
printf( “This ” );
}

3. 如何判断一段程序是由C编译程序还是由C++编译程序编译的?

c++编译时定义了 __cplusplus
c编译时定义了 _STDC_

4. There are two int variables: a and b, don’t use “if”, “? :”, “switch” or other judgement statements, find out the biggest one of the two numbers.

参考答案:
方案一

int max = ((a+b)+abs(a-b)) / 2

方案二

int c = a -b;
char *strs[2] = {“a大”,”b大”};
c = unsigned(c) >> (sizeof(int) * 8 – 1);

【阿尔卡特朗讯笔试题】相关文章:

360笔试题目07-11

华为2017笔试题08-16

华为2017笔试试题08-10

桂林银行笔试题笔经07-20

QMS2007笔试审核知识模拟试题11-02

眼线笔类型-如何挑选眼线笔11-09

马克笔有哪些分类-马克笔的分类11-03

ps笔刷怎么安装08-27

唇线笔怎么用10-11

美甲笔如何保养10-07