日本无码中文字幕片|日本精品在线观看无码视频|国产精品免费啪啪|Av无码一区二区|亚洲在线黄片免费观看|亚洲日韩中文字幕在线观看|熟女激情乱伦在线观看a黄片|成年人观看毛片网址|AV色色色色日韩性草|国产高清无码免费

科目二坡道定點(diǎn)停車與起步的操作方法

時間:2025-11-08 14:34:23 科目二 我要投稿

科目二坡道定點(diǎn)停車與起步的操作方法

  聲明:題目是記憶的,大致意思相同,具體說法有差異,答案是搜索的,僅為參考。

  一、簡答題

  1.c c++內(nèi)存分配。

  代碼區(qū),全局變量與靜態(tài)變量區(qū),局部變量區(qū)即棧區(qū),動態(tài)存儲區(qū),即堆(heap)區(qū)或自由存儲區(qū)(free store)。

  2.數(shù)組和鏈表的區(qū)別。

  (1) 從邏輯結(jié)構(gòu)角度來看

  a, 數(shù)組必須事先定義固定的長度(元素個數(shù)),不能適應(yīng)數(shù)據(jù)動態(tài)地增減的情況。當(dāng)數(shù)據(jù)增加時,可能超出原先定義的元素個數(shù);當(dāng)數(shù)據(jù)減少時,造成內(nèi)存浪費(fèi)。

  b,鏈表動態(tài)地進(jìn)行存儲分配,可以適應(yīng)數(shù)據(jù)動態(tài)地增減的情況,且可以方便地插入、刪除數(shù)據(jù)項(xiàng)。(數(shù)組中插入、刪除數(shù)據(jù)項(xiàng)時,需要移動其它數(shù)據(jù)項(xiàng))

  (2)從內(nèi)存存儲角度來看

  a,(靜態(tài))數(shù)組從棧中分配空間, 對于程序員方便快速,但自由度小。

  b, 鏈表從堆中分配空間, 自由度大但申請管理比較麻煩.

  數(shù)組靜態(tài)分配內(nèi)存,鏈表動態(tài)分配內(nèi)存;

  數(shù)組在內(nèi)存中連續(xù),鏈表不連續(xù);

  數(shù)組元素在棧區(qū),鏈表元素在堆區(qū);

  數(shù)組利用下標(biāo)定位,時間復(fù)雜度為O(1),鏈表定位元素時間復(fù)雜度O(n);

  數(shù)組插入或刪除元素的時間復(fù)雜度O(n),鏈表的時間復(fù)雜度O(1)。

  3.什么是野指針,如何避免?

  野指針,也就是指向不可用內(nèi)存區(qū)域的指針。通常對這種指針進(jìn)行操作的話,將會使程序發(fā)生不可預(yù)知的錯誤。

  “野指針”不是NULL指針,是指向“垃圾”內(nèi)存的指針。人們一般不會錯用NULL指針,因?yàn)橛胕f語句很容易判斷。但是“野指針”是很危險(xiǎn)的,if語句對它不起作用。野指針的成因主要有兩種:

  (1)、指針變量沒有被初始化。任何指針變量剛被創(chuàng)建時不會自動成為NULL指針,它的缺省值是隨機(jī)的,它會亂指一氣。所以,指針變量在創(chuàng)建的同時應(yīng)當(dāng)被初始化,要么將指針設(shè)置為NULL,要么讓它指向合法的內(nèi)存。

  (2)、指針p被free或者delete之后,沒有置為NULL,讓人誤以為p是個合法的指針。別看free和delete的名字惡狠狠的(尤其是delete),它們只是把指針?biāo)傅膬?nèi)存給釋放掉,但并沒有把指針本身干掉。通常會用語句if (p != NULL)進(jìn)行防錯處理。很遺憾,此時if語句起不到防錯作用,因?yàn)榧幢鉷不是NULL指針,它也不指向合法的內(nèi)存塊。例:

  char *p = (char *) malloc(100);

  strcpy(p, “hello”);

  free(p); /pic/p>

  if(p != NULL) /pic/p>

  strcpy(p, “world”); /pic/p>

  4.指針常量和常量指針的區(qū)別?

  int const *p1 = &b;/pic/p>

  int *const p2 = &c;/pic/p>

  5.全局變量是否可以定義在一個文件中,這個頭文件被多個.c文件包含?

  不可以,因?yàn)槊總.c文件引用該.h文件時,會對.h中的函數(shù)重新定義一次。 如果全局變量被定義在可被多個.c文件包含的頭文件中時,就會出現(xiàn)重復(fù)定義。 所以,應(yīng)該是在某個.c文件里面定義,在.h中用extern進(jìn)行聲明

  二、找錯誤

  1.字符處理的問題,將"abc"變成"cba"。

  具體代碼忘記了,主要是strlen問題。

  2.

  1. int main()

  2. {

  3. int a[100];

  4. int **p;

  5. p = &a;

  6. return 0;

  7. }

  找錯

  3.忘記了

  三、編程題

  1.比較字符串大小,如果字符串1大于字符串2,返回1,相等返回0,小于則返回-1;

  1. int strcmp(const char* str1, const char* str2)

  2. {

  3. int ret = 0;

  4. while(!(ret=*(unsigned char*)str1-*(unsigned char*)str2) && *str1)

  5. {

  6. str1++;

  7. str2++

  8. }

  9.

  10.

  11. if (ret < 0)

  12. {

  13. return -1;

  14. }

  15. else if (ret > 0)

  16. {

  17. return 1;

  18. }

  19. return 0;

  20. }

  2.單鏈表反置。

  1. struct ListNode

  2. {

  3. int m_nKey;

  4. ListNode* m_pNext;

  5. };

  6.

  7. #include "stdafx.h"

  8. #include

  9. #include

  10.

  11. using namespace std;

  12.

  13. struct ListNode

  14. {

  15. int m_nKey;

  16. ListNode* m_pNext;

  17. };

  18.

  19. /pic/p>

  20. void CreateList(ListNode *&pHead)

  21. {

  22. fstream fin("list.txt");

  23. ListNode *pNode = NULL;

  24. ListNode *pTmp = NULL;

  25. int data;

  26. fin>>data;

  27. while (data)

  28. {

  29. pNode = new ListNode;

  30. pNode->m_nKey = data;

  31. pNode->m_pNext = NULL;

  32. if (NULL == pHead)

  33. {

  34. pHead = pNode;

  35. pTmp = pNode;

  36. }

  37. else

  38. {

  39. pTmp->m_pNext = pNode;

  40. pTmp = pNode;

  41. }

  42.

  43. fin>>data;

  44. }

  45. }

  46.

  47. /pic/p>

  48. void ReverseLink(ListNode *&pHead)

  49. {

  50. if (NULL == pHead)

  51. {

  52. return;

  53. }

  54. ListNode *pNode = pHead;

  55. ListNode *Prev = NULL;

  56. ListNode *pNext = NULL;

  57. while (NULL != pNode)

  58. {

  59. pNext = pNode->m_pNext;

  60. if (NULL == pNext)

  61. {

  62. pHead = pNode;

  63. }

  64. pNode->m_pNext = Prev;

  65. Prev = pNode;

  66. pNode = pNext;

  67. }

  68. }

  69.

  70. void PrintList(ListNode *pHead)

  71. {

  72. if (NULL == pHead)

  73. {

  74. return;

  75. }

  76. ListNode *pNode = pHead;

  77. while (NULL != pNode)

  78. {

  79. cout<<pNode->m_nKey<<"  "; 

  80. pNode = pNode->m_pNext;

  81. }

  82. cout<<endl;

  83. }

  84.

  85. int _tmain(int argc, _TCHAR* argv[])

  86. {

  87. ListNode *pHead = NULL;

  88. cout<<"原來的鏈表:";

  89. CreateList(pHead);

  90. PrintList(pHead);

  91. ReverseLink(pHead);

  92. cout<<"翻轉(zhuǎn)的鏈表:";

  93. PrintList(pHead);

  94.

  95. return 0;

  96. }

  3.實(shí)現(xiàn)atoi函數(shù)

  1. #include "stdio.h"

  2. #include "ctype.h"

  3. #include "stdlib.h"

  4.

  5. /*

  6. Converts a character string into an int or long

  7. 將一個字符串轉(zhuǎn)化為整數(shù)

  8. */

  9. int my_atoi(char s[])

  10. {

  11. int i,n,sign;

  12.

  13. for(i=0;isspace(s[i]);i++); /pic/p>

  14.

  15. sign=(s[i]=='-')?-1:1;

  16. if(s[i]=='+'||s[i]==' -') /pic/p>

  17. i++;

  18. for(n=0;isdigit(s[i]);i++)

  19. n=10*n+(s[i]-'0'); /pic/p>

  20. return sign*n;

  21. }

  22.

  23. /*

  24. Converts an int or long into a character string

  25. 將一個整數(shù)轉(zhuǎn)化為字符串

  26. */

  27. void my_itoa(int n,char s[])

  28. {

  29. int i,j,sign;

  30.

  31. if((sign=n)<0) /pic/p>

  32. n=-n; /pic/p>

  33. i=0;

  34. do{

  35. s[i++]=n%10+'0'; /pic/p>

  36. }while((n/=10)>0); /pic/p>

  37.

  38. if(sign<0)

  39. s[i++]='-';

  40. s[i]='\0';

  41. for(j=i-1;j>=0;j--) /pic/p>

  42. printf("%c",s[j]);

  43. }

  44.

  45.

  46. void main()

  47. {

  48. int n;

  49. char str[100];

  50. my_itoa(-123,str);

  51. printf("\n");

  52. printf("%d\n",my_atoi("123"));

  53. system("pause");

  54. }

  四、問答

  1.你對衛(wèi)士通的了解?

  2.說出你勝任這份工作的理由?

【科目二坡道定點(diǎn)停車與起步的操作方法】相關(guān)文章:

駕照科目二坡道定點(diǎn)停車與起步07-12

科目二坡道定點(diǎn)停車和起步10-27

科目二坡道定點(diǎn)停車與起步的技巧03-04

坡道定點(diǎn)停車與起步操作方法05-07

科目二坡道定點(diǎn)停車與起步技巧12-24

科目二坡道定點(diǎn)停車與起步操作05-07

科目二考試坡道定點(diǎn)停車與起步02-19

科目二坡道定點(diǎn)停車起步技巧04-18

科目二坡道定點(diǎn)停車與起步妙招09-05

  • 相關(guān)推薦