日韩亚洲专区中文字幕|五月天国产精品免费视频|中文字幕乱码亚州无线码二区|亚洲中文免费AV

<ul id="eu2wk"><blockquote id="eu2wk"></blockquote></ul>
  • <td id="eu2wk"><code id="eu2wk"></code></td>

    當前位置:高考升學網 > 招聘筆試題 > 正文

    2019騰訊校園招聘C語言筆試題和面試題答案(二)

    更新:2023-09-17 16:56:33 高考升學網

      7. 壓縮字符串

      例如字串”aaabbbbccccc”,轉換成相鄰字符+個數的形式壓縮,成為”a3b4c5”。

      (如果有10個數相同)

      假設需要考慮解壓縮

      char MergeString(const char ch)

      {

      char s=(char )malloc(sizeof(ch));

      if(s!=NULL)

      {

      int len=strlen(ch), i=0,j=0,k=0;

      for(;i

      {

      int num=0;

      while(ch[j]==ch[i]) j++,num++;

      s[k++]=ch[i];

      sprintf(s+k,"%d",num);

      k=strlen(s);

      }

      }

      return s;

      }

      8. 如何判斷一個單向鏈表是否有環(huán)。

      int ISCircle(pListNode head)

      {

      pListNode p1=head;

      p1=p1->m_pNext;

      while(p1!=NULL)

      {

      if(p1==head) return 1;

      else p1=p1->m_pNext;

      }

      return 0;

      }

      9. 判斷一個字符串是否對稱。

      aabbaa , efffe返回true

      aabac返回false

      int SymmetricString( const char ch)

      {

      int len=strlen(ch);

      int i=0,j=len-1;

      if(len%2!=0) return 0;

      for(i=0,j=len-1;i<=len/2;i++,j--)

      {

      if(ch[i]!=ch[j]) return 0;

      }

      return 1;

      }

      10. 判斷一個字符串是否是另一個字符串的字串

      int next[20];

      void get_next(const char T,int next[])

      {

      int i=0,j=-1;next[0]=-1;

      int len=strlen(T);

      while(i

      {

      if(j==-1||T[i]==T[j]) {++i;++j;next[i]=j;}

      else j=next[j];

      }

      }

      int index_KMP(const char S,const char T)

      {

      int i=0,j=0;

      get_next(T,next);

      int lens=strlen(S),lent=strlen(T);

      while(i

      if(j==-1 ||S[i]==T[j]){++i;++j;}

      else j=next[j]; }

      if(j>=lent) return i-lent;

      else return -1;

      }

      鏈表的定義,棧的定義:

      typedef struct stack

      {

      int top;

      int space[MAXLEN+1];

      }Stack;

      int push(Stack s,int num)

      {

      if(s->top>=sizeof(s->space)/sizeof(int)) return -1;//Error

      s->space[s->top++]=num;

      return num;

      }

      int pop(Stack s)

      {

      if(s->top<0) return -1;

      return s->space[--s->top];

      }

      int IsEmpty(Stack s)

      {

      return s->top==0;

      }

      typedef struct ListNode

      {

      int m_nKey;

      struct ListNode m_pNext;

      }ListNode,pListNode;

      pListNode CreateList()

      {

      srand((unsigned long)time(NULL));

      pListNode head,p1,p2;

      head=(pListNode)malloc(sizeof(ListNode));

      p1=head;p2=p1;

      int i=MAXLEN;

      while(i--){

      p2=(pListNode)malloc(sizeof(ListNode));

      p2->m_nKey= rand()rand()%(MAXLENrand());

      p1->m_pNext=p2;

      p1=p2;

      }

      p2->m_pNext=NULL;

      return head;

      }

      void PrintList(pListNode head)

      {

      pListNode p=head;

      do{

      printf("%d/n",p->m_nKey);

      p=p->m_pNext;

      }while(p!=NULL); 更多熱門的筆試題目分享:
    湖南廣電筆試真題
    2015華邦軟件工程師筆試題
    光大期貨筆試真題
    馬士基筆試真題筆試題型

    最新圖文

    2020年河北新聞網兩學一做

    時間:2023-09-18 07:0:24

    2020年河北新聞網兩學一做

    時間:2023-09-15 11:0:59

    兩學一做學習教育知

    時間:2023-09-21 06:0:30

    2020年開展兩學一做學習教

    時間:2023-09-19 21:0:30