筆試 & CVTE-嵌入式單片機方向?qū)嵙?/h1>
形式:筆試和視頻題分開考,視頻有2分鐘準備,5分鐘答題;筆試有20(單選多選都有)+2(編程題)有90分鐘。
有感:準備不充分,而且題目填了不能回頭,代碼不能調(diào)試,只能告訴編譯成不成功,唉寄了。
題目知識:
1.查看linux使用了多少內(nèi)存 ——命令cat/proc/meminfo
2.Kill 9命令的意思 向目標進程發(fā)送 SIGKILL 信號(編號為 9)
3.嵌入式存儲速度最快的是A 寄存器組,cache ,內(nèi)存, flash
SRAM與DRAM的區(qū)別
4.哈佛結(jié)構(gòu)
5.嵌入式存儲結(jié)構(gòu)的分配需遵循“Bootloader→內(nèi)核→參數(shù)→文件系統(tǒng)”的物理順序。
存儲區(qū)域 地址范圍 內(nèi)容 大小
Bootloader 0x0800_0000 啟動代碼、中斷向量表 64 KB
內(nèi)核代碼 0x0801_0000 內(nèi)核.text段 512 KB
參數(shù)區(qū) 0x080F_0000 系統(tǒng)配置、校準數(shù)據(jù) 32 KB
文件系統(tǒng) 0x0810_0000 UBIFS分區(qū) 1 MB
6.IIC與SPI的區(qū)別。
7.bootcmd 是 U-Boot 引導加載程序的核心環(huán)境變量,定義了系統(tǒng)啟動時自動執(zhí)行的命令序列
8.線程與進程的區(qū)別
9.USB、UART 異步時序 ; IIC、SPI、PCI同步
視頻題:中斷能不能有延時操作?不能又是為什么?有什么優(yōu)化方案?
編程題:
1.輸入“2FF” 0010 1111 1111 輸出8
#include<bits/stdc++.h> using namespace std; /* 輸入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 */ 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 ; }
2.字符串的頻率
#include<bits/stdc++.h> using namespace std; /* 輸入n個字符串,輸出頻率最高的一個和它的頻率 input: 2AA 【 0010 1111 1111 最長連續(xù)1的個數(shù)為8 】 output: 8 */ //預(yù)設(shè)輸入純數(shù)據(jù),且無其他符號,沒有0x base填寫進制數(shù) unsigned long long My_easy_strtoull( const char *str ,int base){ const char *ptr = str ; unsigned long long res = 0 ; // 轉(zhuǎn)換循環(huán) 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); //統(tǒng)一小寫 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函數(shù)輸入是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++ ){ //字節(jié)數(shù)*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 ; }#筆試#