【原创】每周一题(080129)----面试题解析

C语言零碎知识点 1、不使用sizeof,如何求int占用的字节数 #include <stdio.h> #define MYSIZEOF(value) (char *)(&value+1)-(char *)&value int main() { int i; double f; double *p; printf("%d\n", MYSIZEOF(i)); printf("%d\n", MYSIZEOF(f)); printf("%d\n", ... 阅读详情

评价下面的代码片断:
unsigned int zero = 0;
unsigned int compzero = 0xFFFF;

从表面上来看,这段代码写的没有任何的错误,这是因为在好多人的眼里int型只占两个字节,但是在不是16位的处理器上的时候,这段代码就不正确了!

应该这么写:

unsigned int compzero = ~0;

其实对于一个好的程序员,一个好的嵌入式程序员来讲,应该熟悉每个处理器的字长,好的嵌入式程序员非常准确地明白硬件的细节和它的局限!

我觉得:要写代码就写规范的代码,要写代码就要写可移植性强的代码。

 

【开关电源】开关电源实战经验分享 开关电源原理设计、Layout设计经验分享 阅读详情

相关推荐

Delta并联机构运动学正逆解:从理论建模到Matlab实战

本文深入解析了Delta并联机构运动学正逆解的核心原理与实战方法。通过几何建模,清晰阐述了其“逆解简单、正解复杂”的特性,并详细推导了基于一元二次方程的逆解解析算法与采用牛顿-拉弗森迭代法的正解数值算法。文章结合完整的Matlab代码实例,从符号推导到数值求解,提供了从理论到实践的完整实现路径,助力机器人开发者掌握Delta并联机构的运动学分析。

weixin_29096377的博客 439

C语言经典面试题10道(七)

61.下面的代码输出是什么,为什么? void foo(void) { unsigned int a = 6; int b = -20; (a+b> 6)? puts("> 6") : puts("<= 6"); } 答案:>6 详解:当有符号和无符号运算时,统一转换为无符号,而在有符号的情况下是将最高位置1来表示负数,所以负数转为无符号时将会是一个很大的数。 62.评价下面的代码片断: unsigned int zero = 0; unsign...

weixin_53000184的博客 1605

NXP(imx8qxp)系列DDR校准以及android镜像烧录

文章目录一、 不得不吐槽以下nxp的这个代码镜像烧写的过程,做得太开源了,导致镜像根本烧录不进去,实属令人头痛。 一、

永不秃头的程序员的博客 5993

2021-09-04

嵌入式C语言面试题(二) 1.评价下面的代码 unsigned int zero = 0; unsigned int compzero = 0xFFFF; unsigned int zero = 0; //OK unsigned int compzero = 0xFFFF;//unsigned int 在16位OS中可以这样表示,在32位OS中表示错误. 应该是: unsigned int compzero = ~0; 2.求c=a+++b; int a = 5, b = 7, c; c = a+++

cdma_zte_c的博客 648

kaggle注册以及数据集下载全流程

kaggle注册,数据集下载及常见问题

Arriteey的博客 2万+

YOLO26 从零到工业落地全实战:自定义训练+多场景测试+边缘部署预备,踩坑实测100%可复现

很多人觉得训练是核心,其实不是——数据集的质量,直接决定了你模型的上限。我见过太多人,标注不规范、格式错误、数据集划分混乱,然后疯狂调参,训了几百轮还是不收敛,纯属白费功夫。我这次用的是工业零件缺陷检测自定义数据集,共3个类别:划痕、毛刺、变形,总计1200张图片,给大家讲一套标准的、可复现的数据集制作流程,不管你是做工业检测、安防、交通,都能直接套用。很多人拿到数据集,直接用默认命令训练,然后抱怨精度上不去。默认参数是给COCO数据集用的,你的自定义数据集,必须针对性调参,不然根本达不到最优效果。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 574

面试问题——嵌入式软开1

声明:本文为优快云博主「翟羽嚄」的文章 原文链接:https://blog.youkuaiyun.com/mao_hui_fei/article/details/82710536 1. 用预处理指令#define 声明一个常数,用以表明1年中有多少秒(忽略闰年问题) #define SECONDS_PER_YEAR (60*60*24*365)UL 注意点: (1)#define 语法的基本知识(不能以分号结束,括号的使用……); (2)UL(表示无符号长整型); (3)预处理器可以计算常量表达式的值; (4)

weixin_44348260的博客 588

[QMT量化交易小白入门]-二十四、年化收益47%的全球核心资产轮动策略(含代码解析)

m_days = 25 #动量参考天数period=200m_days被设置为25,表示动量参考的天数为25天;period被设置为200,用于指定获取市场数据的周期长度。

木头大左的博客 2973

C 关于unsigned int compzero = ~0;与unsigned int compzero = 0xFFFF; 的区别!

C 关于unsigned int compzero = ~0;与unsigned int compzero = 0xFFFF; 的区别! unsigned int zero = 0; unsigned int compzero = 0xFFFF; 对于一个int型不是16位的处理器为说,上面的代码是不正确的。应编写如下: unsigned int compzero = ~0; ......

魏波 4864

Proteus-51单片机-LCD1602显示DS1302时钟

本文详细介绍了如何使用Proteus仿真51单片机配合LCD1602显示DS1302时钟的步骤,包括DS1302时钟芯片的主要特性、引脚定义、外围电路以及LCD1602的原理和技术参数。此外,还讲解了LCD1602的指令集和显示字符的方法,并给出了初始化及显示操作的步骤。

让你爱上电路设计 6984

从数据到行动:客服运营必分析的8大核心维度

服务运营正从被动响应升级为数据驱动型战略体系。客服中心的海量交互数据能精准反映服务效能、客户体验及运营短板,关键在于实现数据的可视化与可操作化。本文系统剖析了八类核心数据指标:1)客户行为数据(CSAT/NPS/投诉内容);2)通话效率指标(AHT/接通率);3)服务质量(质检体系/情绪识别);4)坐席绩效(FCR/客户评价);5)流程与知识库(转接率/工单时效);6)渠道流量分析;7)异常预警机制;8)成本收益模型。通过构建多维数据分析体系,企业可在客户全生命周期管理中实现服务升级、风险防控与资源

2202_75469062的博客 1401

嵌入式基础知识整理

嵌入式基础知识整理 宏定义 @ 预处理指令#define 声明一个常数,用以表明1年中有多少秒(忽略闰年问题) #define SECONDS_PER_YEAR (60 * 60 * 24 * 365)UL #define 语法的基本知识(例如:不能以分号结束,括号的使用,等等) 预处理器将为你计算常数表达式的值,因此直接写出你如何计算一年中有多少秒而不是计算出实际的值,是更清晰而没有代价的。...

疯小疯的博客 3000

Qt c++ llama.cpp 运行 LLaMA-3-8B 中文对话机器人(多模态输入)

助手:

寒寒豆豆软件公司的博客 224

几道面试题

 1.for(i=0;i       if(fork()==0)         continue; 一共会生成多少个进程?  http://blog.youkuaiyun.com/hikaliv/archive/2009/06/17/4276758.aspx2.unsigned char * p1;   unsigned char * p2; p1=(unsigned char *)0x01000;

Jasmine's Linux World 896

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

嵌入式面试总结

1. 用预处理指令#define 声明一个常数,用以表明1年中有多少秒(忽略闰年问题) #define SECONDS_PER_YEAR (60 * 60 * 24 * 365)UL 2. 写一个“标准”宏MIN,这个宏输入两个参数并返回较小的一个。 #define MIN(A,B) ((A) &lt;= (B) (A) : ) 三元操作符 4. 嵌入式系统中经常要用到无限循环,你怎么样用...

花茶的博客 689

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

语言的对于处理器的字长问题

unsigned int zero = 0; unsigned int compzero = 0xFFFF; 对于一个int型不是16位的处理器为说,上面的代码是不正确的。应编写如下: signed int compzero = ~0; 为什么会这样,我百度了下,有人这样回答,我觉得不错...

测试0901-1 258

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

【Interview###】华为、中兴嵌入式(C)笔试题

【程序员面试宝典】 1读程序段,回答问题(a) int main(int argc,char *argv[]) { int c=9,d=0; c=c++%5; d=c; printf("d=%d\n",d); return 0; } a)写出程序输出 b)在一个可移植的系统中这种表达式是否存在风险?why? 答案:5 存在风险,因为c=c++%5;这个表达式对c有两次修改,行为...

好习惯成就伟大 1万+

每日一题(53)—— 评价代码片段

评价下面代码片段: unsigned int zero = 0; unsigned int compzero = 0xFFFF; /*1's complement of zero */ 对于一个int型不是16位的处理器为说,上面的代码是不正确的。应编写如下:  unsigned int compzero= ~0;       这一问题

血染风采2019 1736

C 关于unsigned int compzero = ~0;

unsigned int zero = 0;  unsigned int compzero = 0xFFFF;  /*1's complement of zero */  对于一个int型不是16位的处理器为说,上面的代码是不正确的。应编写如下:  unsigned int compzero = ~0;  为什么啊? 网友回复:unsigned int comp

Health's Box 1872

常见嵌入式C问题

常见嵌入式C问题进程与线程的区别 进程与线程的区别 进程,是对操作系统正在运行程序的一个抽象。操作系统会把每个运行中的程序封装成独立的实体,分配各自所需要的资源,在根据调度算法切换执行,这个抽象的实体就是进程。因此进程是操作系统机型资源分配和调度的一个基本单位。 进程是任务调度的最小单位,每个进程有自己的独立代码和数据空间,使得各个进程之间内存地址相互隔离。 随着应用程序功能设计的越来越复杂,应用程序中的某种活动可能被阻塞,自然而然的想着能不能把这些应用程序分解成更细的粒度,能“并行”的执行多个执行实体,并

BeginnerMind 2026

C语言面试及答案分析 第二部分 程序代码评价或者找错

第二部分:程序代码评价或者找错 1、下面的代码输出是什么,为什么? void foo(void) { unsigned int a = 6; int b = -20; (a+b > 6) ? puts(“> 6″) : puts(“<= 6"); } 这个问题测试你是否懂得C语言中的整数自动转换原则,我发现有些开发者懂得极少这些东西。 不管如何,这无符号整型问题的答案是输出是 ">6″。 原因是当表达式中存在有符号类型和无符号类型时所有的操作数都自动转换为无符号类型。因此-2

happy_teemo的博客 4584

【常见c语言笔试题嵌入式软件开发1】

常见c语言笔试题嵌入式软件开发 本次进行分享的是嵌入式软件开发中常见的一些c语言知识相关的笔试题 内容来自B站博主: c语言笔试题嵌入式软件开发视频 1.char *const *(*next)()请对这行代码进行解释 1)首先这题考的知识点有函数指针 2)const 和指针之间的关系(指向常量的指针,以及常量指针) 代码解释: 1、(*next) 中next是一个指针 2、(*next)() next是一个函数指针 3、 char *const 是一个指针 常量指针 综合理解:next是个函数

boybs的博客 1322

题海拾贝No.9|C语言笔试->程序代码评价或者找错

程序代码评价或者找错题目及解析 题目及解析 1、下面的代码输出是什么,为什么? void foo(void) { unsigned int a = 6; int b = -20; (a+b > 6) ? puts(“> 6″) : puts(“<= 6"); } 这个问题测试你是否懂得C语言中的整数自动转换原则,不管如何,这无符号整型问题的答案是输出是 ">6″。原因是当表达式中存在有符号类型和无符号类型时所有的操作数都自动转换为无符号类型。因此-20变成了一个非常大的正整数,所以

weixin_44035986的博客 950

嵌入式笔试题(2)

1. 关键字 static的作用是什么? 这个简单的问题很少有人能回答完全。在C语言中,关键字static有三个明显的作用: 1) 在函数体,一个被声明为静态的变量在这一函数被调用过程中维持其值不变。 2) 在模块内(但在函数体外),一个被声明为静态的变量可以被模块内所用函数访问, 但不能被模块外其它函数访问。它是一个本地的全局变量。 3) 在模块内,一个被声明为静态的函数只可被这一模块内

努力学习的函姐姐 536
上一篇: Linux Programing
下一篇: 【原创】有关C语言预处理器的研究
SmallBox00
博客等级 码龄20年 61粉丝 307原创
评论 5
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值