1. <tt id="5hhch"><source id="5hhch"></source></tt>
    1. <xmp id="5hhch"></xmp>

  2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

    <rp id="5hhch"></rp>
        <dfn id="5hhch"></dfn>

      1. c 面試題目

        時間:2020-11-08 09:06:18 面試問題 我要投稿

        c 面試題目

        1、outputstr 所指的值為 123456789
        int continumax(char *outputstr, char *inputstr)
        {
        char *in = inputstr, *out = outputstr, *temp, *final;
        int count = 0, maxlen = 0;
        while( *in != '\0' )
        {
        if( *in > 47 && *in < 58 )
        {
        for(temp = in; *in > 47 && *in < 58 ; in++ )
        count++;
        }
        else
        in++;
        if( maxlen < count )
        {
        maxlen = count;
        count = 0;
        final = temp;
        }
        }
        for(int i = 0; i < maxlen; i++)
        {
        *out = *final;
        out++;
        final++;
        }
        *out = '\0';
        return maxlen;
        }
        2、不用庫函數,用 C 語言實現將一整型數字轉化為字符串
        方法 1:
        int getlen(char *s){
        int n;
        for(n = 0; *s != '\0'; s++)
        n++;
        return n;
        }
        void reverse(char s[])
        {
        int c,i,j;
        for(i = 0,j = getlen(s) - 1; i < j; i++,j--){
        c = s[i];
        s[i] = s[j];
        s[j] = c;
        }
        }
        void itoa(int n,char s[])
        {
        int i,sign;
        if((sign = n) < 0)
        n = -n;
        i = 0;
        do{/*以反序生成數字*/
        s[i++] = n%10 + '0';/*get next number*/
        }while((n /= 10) > 0);/*delete the number*/
        if(sign < 0)
        s[i++] = '-';
        s[i] = '\0';
        reverse(s);
        }
        方法 2:
        #include <iostream>
        using namespace std;
        void itochar(int num);
        void itochar(int num)
        {
        int i = 0;
        int j ;
        char stra[10];
        char strb[10];
        while ( num )
        {
        stra[i++]=num%10+48;
        num=num/10;
        }
        stra[i] = '\0';
        for( j=0; j < i; j++)
        {
        strb[j] = stra[i-j-1];
        }
        strb[j] = '\0';
        cout<<strb<<endl;
        }
        int main()
        {
        int num;
        cin>>num;
        itochar(num);
        return 0;
        }
        3、求組合數: 求 n 個數(1....n)中 k 個數的組合....
        如:combination(5,3)
        要求輸出:543,542,541,532,531,521,432,431,421,321,
        #include<stdio.h>
        int pop(int *);
        int push(int );
        void combination(int ,int );
        int stack[3]={0};
        top=-1;
        int main()
        {
        int n,m;
        printf("Input two numbers:\n");
        while( (2!=scanf("%d%*c%d",&n,&m)) )
        {
        fflush(stdin);
        printf("Input error! Again:\n");
        }
        combination(n,m);
        printf("\n");
        }
        void combination(int m,int n)
        {
        int temp=m;
        push(temp);
        while(1)
        {
        if(1==temp)
        {
        if(pop(&temp)&&stack[0]==n) //當棧底元素彈出&&為可能取的最小值,循環退出break;
        }
        else if( push(--temp))
        {
        printf("%d%d%d ",stack[0],stack[1],stack[2]);//§&auml;¨ì¤@?
        pop(&temp);
        }
        }
        }
        int push(int i)
        {
        stack[++top]=i;
        if(top<2)
        return 0;
        else
        return 1;
        }
        int pop(int *i)
        {
        *i=stack[top--];
        if(top>=0)
        return 0;
        else
        return 1;
        }

        【c 面試題目】相關文章:

        C/C++面試題目11-21

        C C++面試筆試題目集錦11-15

        C++面試筆試題目11-21

        實用C++面試筆試題目11-21

        經典c++面試筆試題目11-21

        Jr.C++/C#開發工程師面試筆試題目11-15

        經典c++面試筆試題目22題11-21

        C++筆試題目分享11-22

        2016年華為認證C/C++筆試題目11-06

        北承筆試題目(C++)11-23

        国产高潮无套免费视频_久久九九兔免费精品6_99精品热6080YY久久_国产91久久久久久无码

        1. <tt id="5hhch"><source id="5hhch"></source></tt>
          1. <xmp id="5hhch"></xmp>

        2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

          <rp id="5hhch"></rp>
              <dfn id="5hhch"></dfn>