笔试 & CVTE-嵌入式单片机方向实习
形式:笔试和视频题分开考,视频有2分钟准备,5分钟答题;笔试有20(单选多选都有)+2(编程题)有90分钟。
有感:准备不充分,而且题目填了不能回头,代码不能调试,只能告诉编译成不成功,唉寄了。
题目知识:
1.查看linux使用了多少内存 ——命令cat/proc/meminfo
2.Kill 9命令的意思 向目标进程发送 SIGKILL 信号(编号为 9)
3.嵌入式存储速度最快的是A 寄存器组,cache ,内存, flash
SRAM与DRAM的区别
4.哈佛结构
5.嵌入式存储结构的分配需遵循“Bootloader→内核→参数→文件系统”的物理顺序。
存储区域 地址范围 内容 大小
Bootloader 0x0800_0000 启动代码、中断向量表 64 KB
内核代码 0x0801_0000 内核.text段 512 KB
参数区 0x080F_0000 系统配置、校准数据 32 KB
文件系统 0x0810_0000 UBIFS分区 1 MB
6.IIC与SPI的区别。
7.bootcmd 是 U-Boot 引导加载程序的核心环境变量,定义了系统启动时自动执行的命令序列
8.线程与进程的区别
9.USB、UART 异步时序 ; IIC、SPI、PCI同步
视频题:中断能不能有延时操作?不能又是为什么?有什么优化方案?
编程题:
1.输入“2FF” 0010 1111 1111 输出8
/*
题目: 输入字符串,内容是十六进制数,输出连续1最长是多少。
input:
2FF
【 0010 1111 1111 最长连续1的个数为8 】
output:
8
*/
#include<bits/stdc++.h>
using namespace std;
//预设输入纯数据,且无其他符号,没有0x base填写进制数
unsigned long long My_easy_strtoull( const char *str ,int base){
const char *ptr = str ;
unsigned long long res = 0 ;
// 转换循环
for (; *ptr != '\0'; ptr++) {
int digit;
if (isdigit(*ptr) && (*ptr - '0') < base) { //是否0-9
digit = *ptr - '0';
} else if (isalpha(*ptr)) { //是否字母
char c = tolower(*ptr); //统一小写
if (c >= 'a' && c < 'a' + base - 10) {
digit = c - 'a' + 10;
} else {
break; // 非法字符
}
} else {
break; // 非法字符
}
res = res * base + digit;
}
return res ;
}
int strhex_to_max_ones(const char *hex_str){
int res = 0 ;
char *endptr ; //char **endptr ; strtoull函数输入是char** ,这里定义char* ,再取地址也是一样的
//unsigned long long num = strtoull(hex_str, &endptr, 16) ;
unsigned long long num = My_easy_strtoull(hex_str,16) ;
printf("%lld\n",num);
int max_count = 0 ;
int current_count = 0 ;
for( int i = 0 ; i < sizeof(num)*8 ; i++ ){ //字节数*8 = bit位
if( (num >> i) & 1ULL ){
current_count++ ;
max_count = (current_count > max_count) ? current_count : max_count ;
}else{
current_count = 0 ;
}
}
res = max_count ;
return res ;
}
int main()
{
char str[8] ;
scanf("%s",str);
int ans = strhex_to_max_ones(str);
printf("%d\n",ans);
return 0 ;
}
2.字符串的频率
/*
题目: 输入n个字符串,输出频率最高的一个和它的频率
input:
5
168.192.0.1 2021-01-02T00:11:11
168.192.0.2 2021-01-02T00:11:11
168.192.0.3 2021-01-02T00:11:11
168.192.0.1 2021-01-02T00:11:11
168.192.0.1 2021-01-02T00:11:11
output:
168.192.0.1 3
*/
#include<bits/stdc++.h>
using namespace std;
typedef struct {
char *str ;
int count ;
}String_T;
int main()
{
int different_count = 0 ;
char temp[35];
char str_in[35];
int n ;
scanf("%d\n",&n);
String_T *list = ( String_T* )malloc( n*sizeof( String_T ) );
for( int i = 0 ; i < n ; i++ ){
if( i == n-1 ) { scanf("%s %s",str_in ,temp ); }
else { scanf("%s %s\n",str_in , temp ); }
bool flag_finish = false ; //没操作本次输入
for( int j = 0 ; j < different_count ; j++ ){
if( strcmp( list[j].str , str_in ) == 0 ){
list[j].count++ ;
flag_finish = true ;
}
}
if( flag_finish == false ){ //没操作,说明是新的字符串
list[different_count].str = strdup( str_in ) ;//需要配备free
list[different_count].count = 1 ;
different_count++ ;
}
}
int max_count = 0 ;
for( int i = 0 ; i < different_count ; i++ ){
if( list[i].count > max_count ){
max_count = list[i].count ;
}
}
for( int i = 0 ; i < different_count ; i++ ){
if( list[i].count == max_count ){
printf("%s %d\n",list[i].str , max_count);
break ;
}
}
//free
for( int i = 0 ; i < different_count ; i++ ){
free( list[i].str );
}
free( list );
return 0 ;
}
#笔试#