1024国产,91精品国产综合久久福利,中文字幕成人免费视频,日本人的色道免费网站,曰本一级毛片免费,www.日日爱,国产黑丝视频

當(dāng)前位置:高考升學(xué)網(wǎng) > 招聘筆試題 > 正文

衛(wèi)士通2019年筆試真題(二)

更新:2023-09-17 16:59:33 高考升學(xué)網(wǎng)

  三、編程題

  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. //構(gòu)造鏈表

  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. //翻轉(zhuǎn)單鏈表

  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<

m_nKey<<" ";

  80. pNode = pNode->m_pNext;

  81. }

  82. cout<

  83. }

  84.

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

  86. {

  87. ListNode pHead = NULL;

  88. cout<<"原來(lái)的鏈表:";

  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. 將一個(gè)字符串轉(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++); //跳過(guò)空白

  14.

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

  16. if(s[i]=='+'||s[i]==' -') //跳過(guò)符號(hào)位

  17. i++;

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

  19. n=10n+(s[i]-'0'); //將數(shù)字字符轉(zhuǎn)換成整形數(shù)字

最新圖文

2020年河北新聞網(wǎng)兩學(xué)一做

時(shí)間:2023-09-18 07:0:24

2020年河北新聞網(wǎng)兩學(xué)一做

時(shí)間:2023-09-15 11:0:59

兩學(xué)一做學(xué)習(xí)教育知

時(shí)間:2023-09-21 06:0:30