中文字幕在线一区二区在线,久久久精品免费观看国产,无码日日模日日碰夜夜爽,天堂av在线最新版在线,日韩美精品无码一本二本三本,麻豆精品三级国产国语,精品无码AⅤ片,国产区在线观看视频

      華為認(rèn)證考試題庫(kù)

      時(shí)間:2024-10-24 02:39:33 華為認(rèn)證 我要投稿

      2016年華為認(rèn)證考試題庫(kù)

        華為認(rèn)證覆蓋路由交換、無(wú)線局域網(wǎng)、無(wú)線、傳送網(wǎng)、安全、統(tǒng)一通信、視訊、云計(jì)算、服務(wù)器、存儲(chǔ)以及ICT融合設(shè)計(jì)等11個(gè)技術(shù)領(lǐng)域。下面快跟yjbys小編一起來(lái)看看關(guān)于華為認(rèn)證的考試題庫(kù),希望能幫助到各位考生!

      2016年華為認(rèn)證考試題庫(kù)

        1.第一題的題目大概是輸入整型數(shù)組求數(shù)組的最小數(shù)和最大數(shù)之和,例如輸入1,2,3,4則輸出為5,當(dāng)輸入只有一個(gè)數(shù)的時(shí)候,則最小數(shù)和最大數(shù)都是該數(shù),例如只輸入1,則輸出為2;另外數(shù)組的長(zhǎng)度不超過(guò)50

        #include

        main()

        {

        intnum[50]={0};

        inti,n;

        printf("請(qǐng)輸入整型數(shù)組的長(zhǎng)度(1~50):");

        scanf("%d",&n);

        printf("請(qǐng)輸入整型數(shù)組的元素:");

        for(i=0;i

        {

        scanf("%d",&num[i]);

        }

        intmin_num=num[0];

        intmax_num=num[0];

        for(intj=0;j

        {

        if(max_num

        max_num=num[j];

        elseif(min_num>num[j])

        min_num=num[j];

        }

        intsum=min_num+max_num;

        printf("數(shù)組中最大與最小值之和:%d\n",sum);

        return0;

        }

        2.求兩個(gè)長(zhǎng)長(zhǎng)整型的數(shù)據(jù)的和并輸出,例如輸入1233333333333333。。。 3111111111111111111111111.。。。,則輸出。。。。

        #include

        #include

        #include

        main()

        {

        char*num1,*num2; //兩個(gè)長(zhǎng)長(zhǎng)整型數(shù)據(jù)

        char*sum;

        // inttemp;

        int len_num1,len_num2; // 兩個(gè)長(zhǎng)長(zhǎng)整型數(shù)據(jù)的長(zhǎng)度

        intlen_max,len_min;

        num1=(char*)malloc(sizeof(char));

        num2=(char*)malloc(sizeof(char));

        printf("輸入兩個(gè)長(zhǎng)長(zhǎng)整型數(shù)據(jù):");

        scanf("%s",num1);

        printf("輸入兩個(gè)長(zhǎng)長(zhǎng)整型數(shù)據(jù):");

        scanf("%s",num2);

        len_num1=strlen(num1);

        len_num2=strlen(num2);

        len_max=(len_num1>=len_num2)?len_num1:len_num2;

        len_min=(len_num1<=len_num2)?len_num1:len_num2;

        int len_max1=len_max;

        sum=(char*)malloc(sizeof(char)*len_max);

        memset(sum,0x00,len_max+1);//切忌初始化

        for(;len_num1>0&&len_num2>0;len_num1--,len_num2--)

        {

        sum[len_max--]=((num1[len_num1-1]-'0')+(num2[len_num2-1]-'0'));

        }

        if(len_num1>0)

        {

        sum[len_max--]=num1[len_num1- 1 ]-'0';

        len_num1--;

        }

        if(len_num2>0)

        {

        sum[len_max--]=num1[len_num2- 1]-'0';

        len_num2--;

        }

        for(intj=len_max1;j>=0;j--) //實(shí)現(xiàn)進(jìn)位操作

        {

        // temp=sum[j]-'0';

        if(sum[j]>=10)

        {

        sum[j-1]+=sum[j]/10;

        sum[j]%=10;

        }

        }

        char*outsum=(char*)malloc(sizeof(char)*len_max1);

        j=0;

        while(sum[j]==0) //跳出頭部0元素

        j++;

        for(int m=0;m

        outsum[m]=sum[j]+'0';

        outsum[m]='\0';

        printf("輸出兩長(zhǎng)長(zhǎng)整型數(shù)據(jù)之和:%s\n",outsum);

        return0;

        }

        3.通過(guò)鍵盤輸入一串小寫字母(a~z)組成的字符串。請(qǐng)編寫一個(gè)字符串過(guò)濾程序,若字符串中出現(xiàn)多個(gè)相同的字符,將非首次出現(xiàn)的字符過(guò)濾掉。

        比如字符串“abacacde”過(guò)濾結(jié)果為“abcde”。

        要求實(shí)現(xiàn)函數(shù):

        void stringFilter(const char *pInputStr,long lInputLen, char *pOutputStr);

        【輸入】 pInputStr:輸入字符串

        lInputLen: 輸入字符串長(zhǎng)度

        【輸出】 pOutputStr:輸出字符串,空間已經(jīng)開辟好,與輸入字符串等長(zhǎng);

        #include

        #include

        #include

        void stringFilter(const char *p_str, longlen, char *p_outstr)

        {

        intarray[256]={0};

        const char *tmp = p_str;

        for(int j=0;j

        {

        if(array[tmp[j]]==0)

        *p_outstr++=tmp[j];

        array[tmp[j]]++;

        }

        *p_outstr= '\0';

        }

        void main()

        {

        char *str = "cccddecc";

        intlen = strlen(str);

        char* outstr = (char *)malloc(len*sizeof(char));

        stringFilter(str,len,outstr);

        printf("%s\n",outstr);

        free(outstr);

        outstr= NULL;

        }

        4.通過(guò)鍵盤輸入一串小寫字母(a~z)組成的字符串。請(qǐng)編寫一個(gè)字符串壓縮程序,將字符串中連續(xù)出席的重復(fù)字母進(jìn)行壓縮,并輸出壓縮后的字符串。

        壓縮規(guī)則:

        1. 僅壓縮連續(xù)重復(fù)出現(xiàn)的字符。比如字符串"abcbc"由于無(wú)連續(xù)重復(fù)字符,壓縮后的字符串還是"abcbc".

        2. 壓縮字段的格式為"字符重復(fù)的次數(shù)+字符"。例如:字符串"xxxyyyyyyz"壓縮后就成為"3x6yz"

        要求實(shí)現(xiàn)函數(shù):

        void stringZip(const char*pInputStr, long lInputLen, char *pOutputStr);

        【輸入】 pInputStr: 輸入字符串

        lInputLen: 輸入字符串長(zhǎng)度

        【輸出】 pOutputStr: 輸出字符串,空間已經(jīng)開辟好,與輸入字符串等長(zhǎng);

        #include

        #include

        #include

        void stringZip(const char *p_str, long len,char *p_outstr)

        {

        intcount=1;

        for(inti=0;i

        {

        if(p_str[i]==p_str[i+1])

        {

        count++;

        }

        else

        {

        if(count>1)

        {

        *p_outstr++= count +'0';

        *p_outstr++=p_str[i];

        }

        else

        {

        *p_outstr++=p_str[i];

        }

        count = 1;//注意其位置

        }

        }

        *p_outstr= '\0';

        }

        void main()

        {

        char*str = "cccddecc";

        printf("壓縮之前的字符串為:%s\n",str);

        intlen = strlen(str);

        char* outstr = (char*)malloc(len*sizeof(char));

        stringZip(str,len,outstr);

        printf("壓縮之后的字符串為:%s\n",outstr);

        free(outstr);

        outstr= NULL;

        }

        5.通過(guò)鍵盤輸入100以內(nèi)正整數(shù)的加、減運(yùn)算式,請(qǐng)編寫一個(gè)程序輸出運(yùn)算結(jié)果字符串。

        輸入字符串的格式為:“操作數(shù)1 運(yùn)算符 操作數(shù)2”,“操作數(shù)”與“運(yùn)算符”之間以一個(gè)空格隔開。

        補(bǔ)充說(shuō)明:

        1. 操作數(shù)為正整數(shù),不需要考慮計(jì)算結(jié)果溢出的情況。

        2. 若輸入算式格式錯(cuò)誤,輸出結(jié)果為“0”。

        要求實(shí)現(xiàn)函數(shù):

        void arithmetic(const char*pInputStr, long lInputLen, char *pOutputStr);

        【輸入】 pInputStr: 輸入字符串

        lInputLen: 輸入字符串長(zhǎng)度

        【輸出】 pOutputStr: 輸出字符串,空間已經(jīng)開辟好,與輸入字符串等長(zhǎng);

        #include

        #include

        #include

        void arithmetic(const char *input, longlen, char *output)

        {

        chars1[10];

        chars2[10];

        chars3[10];

        intcnt = 0;

        intlen_input=strlen(input);

        for(inti=0;i

        {

        if(input[i]=='')

        cnt++;

        }

        if(cnt!=2)

        {

        *output++= '0';

        *output= '\0';

        return;

        }

        sscanf(input,"%s %s %s",s1,s2,s3);

        if(strlen(s2)!=1||(s2[0]!='+'&&s2[0]!='-'))

        {

        *output++= '0';

        *output= '\0';

        return;

        }

        int len_s1=strlen(s1);

        for(i=0;i

        {

        if(s1[i]<'0'||s1[i]>'9')

        {

        *output++= '0';

        *output= '\0';

        return;

        }

        }

        intlen_s3=strlen(s3);

        for(i=0;i

        {

        if(s3[i]<'0'||s3[i]>'9')

        {

        *output++= '0';

        *output= '\0';

        return;

        }

        }

        int x = atoi(s1);

        int y = atoi(s3);

        if(s2[0]=='+')

        {

        intresult = x+y;

        itoa(result,output,10);

        }

        elseif(s2[0]=='-')

        {

        intresult = x-y;

        itoa(result,output,10);

        }

        else

        {

        *output++= '0';

        *output= '\0';

        return;

        }

        }

        void main()

        {

        charstr[] = {"10 - 23"};

        charoutstr[10];

        intlen = strlen(str);

        arithmetic(str,len,outstr);

        printf("%s\n",str);

        printf("%s\n",outstr);

        }

        6.一組人(n個(gè)),圍成一圈,從某人開始數(shù)到第三個(gè)的人出列,再接著從下一個(gè)人開始數(shù),最終輸出最終出列的人

        (約瑟夫環(huán)是一個(gè)數(shù)學(xué)的應(yīng)用問(wèn)題:已知n個(gè)人(以編號(hào)1,2,3...n分別表示)圍坐在一張圓桌周圍。從編號(hào)為k的人開始報(bào)數(shù),數(shù)到m的那個(gè)人出列;他的下一個(gè)人又從1開始報(bào)數(shù),數(shù)到m的那個(gè)人又出列;依此規(guī)律重復(fù)下去,直到圓桌周圍的人全部出列。)

        #include

        #include

        #include

        #include

        typedef struct Node

        {

        intdata;

        structNode *next;

      更多相關(guān)文章推薦閱讀:

      1.2016年華為認(rèn)證考試題庫(kù)

      2.2016年華為hcie認(rèn)證考試題庫(kù)

      3.2016年華為認(rèn)證認(rèn)證試題(筆試)

      4.2016年華為認(rèn)證考試題及答案

      5.2016年華為上機(jī)考試題

      6.2016年華為HCDA認(rèn)證考試題庫(kù)

      7.2016年華為筆試題及及答案

      8.2016年華為筆試面試題及答案

      9.2016年華為HCDA認(rèn)證考試筆試題及答案

        }LinkList;

        LinkList *create(int n)

        {

        LinkList*p,*q,*head;

        inti=1;

        p=(LinkList*)malloc(sizeof(LinkList));

        p->data=i;

        head=p;

        for(i=1;i<=n;i++)

        {

        q=(LinkList*)malloc(sizeof(LinkList));

        q->data=i+1;

        p->next=q;

        p=q;

        }

        p->next=head; //使鏈表尾連接鏈表頭,形成循環(huán)鏈表

        returnhead;

        free(p);

        p=NULL;

        free(q);

        q=NULL;

        }

        void deletefun(LinkList *L,int m)

        {

        LinkList*p,*q,*temp;

        inti;

        p=L;

        while(p->next!=p)

        {

        for(i=1;i

        {

        q=p;

        p=p->next;

        }

        printf("%5d",p->data);

        temp=p;

        q->next=p->next;

        p=p->next;

        free(temp);

        }

        printf("%5d\n",p->data);

        }

        int main()

        {

        intn=7,m=3;

        LinkList*head1;

        head1=create(n);

        deletefun(head1,m);

        return0;

        }

        7..輸入一串字符,只包含“0-10”和“,”找出其中最小的數(shù)字和最大的數(shù)字(可能不止一個(gè)),輸出最后剩余數(shù)字個(gè)數(shù)。如輸入 “3,3,4,5,6,7,7”

        #include

        #include

        #include

        void main()

        {

        charstr[100];

        printf("輸入一組字符串:\n");

        scanf("%s",&str);

        intlen=strlen(str);

        intarray[100];

        intcount=0;

        for(inti=0;i

        {

        if(str[i]>='0'&&str[i]<='9')

        array[count++]=str[i]-'0';

        }

        array[count]='\0';

        intresult=count;

        intmin=array[0];

        intmax=array[0];

        for(intj=0;j

        {

        if(max

        max=array[j];

        elseif(min>array[j])

        min=array[j];

        }

        for(intk=0;k

        {

        if(array[k]==min)

        result--;

        if(array[k]==max)

        result--;

        }

        printf("%d\n",result);

        }

        8.輸入一組身高在170到190之間(5個(gè)身高),比較身高差,選出身高差最小的兩個(gè)身高;若身高差相同,選平均身高高的那兩個(gè)身高;從小到大輸出;

        如 輸入 170 181173 186 190 輸出 170 173

        #include

        #include

        #define N 5

        int main()

        {

        intHeight[N];

        intdmin;

        intH1,H2;

        inti,j,temp;

        printf("請(qǐng)輸入一組身高在170到190之間的數(shù)據(jù)(共5個(gè)):\n");

        for(intk=0;k

        scanf("%d",&Height[k]);

        printf("\n");

        for(i=0;i

        for(j=1;jHeight[j];j++)

        {

        temp=Height[j-1];

        Height[j-1]=Height[j];

        Height[j]=temp;

        }

        H1=Height[0];

        H2=Height[1];

        dmin=H2-H1;

        for(intm=2;m

        {

        if(Height[m]-Height[m-1]<=dmin)

        {

        H1=Height[m-1];

        H2=Height[m];

        dmin=Height[m]-Height[m-1];

        }

        }

        printf("身高差最小的兩個(gè)身高為:\n");

        printf("%d,%d\n",H1,H2);

        return0;

        }

        9. 刪除子串,只要是原串中有相同的子串就刪掉,不管有多少個(gè),返回子串個(gè)數(shù)。

        #include

        #include

        #include

        #include

        int delete_sub_str(const char *str,constchar *sub_str,char *result)

        {

        assert(str!= NULL && sub_str != NULL);

        constchar *p,*q;

        char*t,*temp;

        p= str;

        q= sub_str;

        t= result;

        intn,count = 0;

        n= strlen(q);

        temp= (char *)malloc(n+1);

        memset(temp,0x00,n+1);

        while(*p)

        {

        memcpy(temp,p,n);

        if(strcmp(temp,q)== 0 )

        {

        count++;

        memset(temp,0x00,n+1);

        p= p + n;

        }

        else

        {

        *t= *p;

        p++;

        t++;

        memset(temp,0x00,n+1);

        }

        }

        free(temp);

        returncount;

        }

        void main()

        {

        chars[100] = {‘\0’};

        intnum = delete_sub_str(“123abc12de234fg1hi34j123k”,”123”,s);

        printf(“Thenumber of sub_str is %d\r\n”,num);

        printf(“Theresult string is %s\r\n”,s);

        }

        10. 要求編程實(shí)現(xiàn)上述高精度的十進(jìn)制加法。要求實(shí)現(xiàn)函數(shù):

        void add (const char *num1,const char *num2, char *result)

        【輸入】num1:字符串形式操作數(shù)1,如果操作數(shù)為負(fù),則num1[0]為符號(hào)位'-'

        num2:字符串形式操作數(shù)2,如果操作數(shù)為負(fù),則num2[0]為符號(hào)位'-'

        【輸出】result:保存加法計(jì)算結(jié)果字符串,如果結(jié)果為負(fù),則result[0]為符號(hào)位。

        #include

        #include

        #include

        void move(char *str, int length) //移除字母前的"-"符號(hào)

        {

        if(str[0] != '-')

        return;

        int i;

        for(i = 0; i < length-1; i++)

        str[i] = str[i+1];

        str[i] = '\0';

        }

        intremove_zero(char *result, int length)

        {

        int count = 0;

        for(int i = length-1; i > 0; i--) //從最后開始移除0,直到遇到非0數(shù)字,只對(duì)最初位置上的0不予判斷

        {

        if(result[i] == '0')

        {

        result[i] = '\0';

        count++;

        }else

        return length-count;

        }

        return length - count;

        }

        voidreverse(char *result, int length) //將字符串倒轉(zhuǎn)

        {

        char temp;

        for(int i = 0; i <= (length-1)/2; i++)

        {

        temp = result[i];

        result[i] = result[length-1-i];

        result[length-1-i] = temp;

        }

        }

        intreal_add(char *str1, char *str2, char *result, const bool flag)

        {

        int len1 = strlen(str1);

        int len2 = strlen(str2);

        int n1, n2, another = 0; //another表示進(jìn)位

        int cur_rs = 0; //表示result的當(dāng)前位數(shù)

        int i, j;

        int curSum;

        for(i = len1-1, j = len2-1; i >= 0 && j >= 0; i--, j--)

        {

        n1 = str1[i] - '0';

        n2 = str2[j] - '0';

        curSum = n1 + n2 + another;

        result[cur_rs++] = curSum % 10 + '0';

        another = curSum / 10;

        }

        if(j < 0)

        {

        while(i >= 0) //遍歷str1剩余各位

        {

        n1 = str1[i--] - '0';

        curSum = n1 + another;

        result[cur_rs++] = curSum % 10 + '0';

        another = curSum / 10;

        }

        if(another != 0) //如果還有進(jìn)位未加上

        result[cur_rs++] = another + '0';

        }

        else

        {

        while(j >= 0)

        {

        n2 = str2[j--] - '0';

        curSum = n2 + another;

        result[cur_rs++] = curSum % 10 + '0';

        another = curSum / 10;

        }

        if(another != 0)

        result[cur_rs++] = another + '0';

        }

        result[cur_rs] = '\0';

        cur_rs = remove_zero(result, cur_rs);

        if(!flag)

        {

        result[cur_rs++] = '-';

        result[cur_rs] = '\0';

        }

        reverse(result, strlen(result));

        return cur_rs;

        }

        intreal_minus(char *str1, char *str2, char *result) //使用str1減去str2

        {

        char big[100], small[100];

        int big_len, sml_len;

        int len1 = strlen(str1);

        int len2 = strlen(str2);

        bool flag = false; //用于標(biāo)記str2是否比str1大

        if(len1 < len2)

        flag = true;

        else if(len1 == len2)

        {

        if(strcmp(str1, str2) == 0)

        {

        result[0] = '0';

        result[1] = '\0';

        return 1;

        }else if(strcmp(str1,str2) < 0)

        flag = true;

        }

        if(flag) //將str1和str2交換,確保str1指向的值是其中較大者,最后通過(guò)flag確定要不要給前面加-號(hào)

        {

        char *temp = str1;

        str1 = str2;

        str2 = temp;

        len1 = strlen(str1);

        len2 = strlen(str2);

        }

        int n1, n2, another = 0; //another表示是否有借位

        int i, j;

        int cur_rs = 0;

        int curMinus;

        for(i = len1-1, j =len2-1; i>=0 && j>=0; i--,j--)

        {

        n1 = str1[i] - '0';

      更多相關(guān)文章推薦閱讀:

      1.2016年華為認(rèn)證考試題庫(kù)

      2.2016年華為hcie認(rèn)證考試題庫(kù)

      3.2016年華為認(rèn)證認(rèn)證試題(筆試)

      4.2016年華為認(rèn)證考試題及答案

      5.2016年華為上機(jī)考試題

      6.2016年華為HCDA認(rèn)證考試題庫(kù)

      7.2016年華為筆試題及及答案

      8.2016年華為筆試面試題及答案

      9.2016年華為HCDA認(rèn)證考試筆試題及答案

        n2 = str2[j] - '0';

        if(n1 >= n2+another)

        {

        result[cur_rs++] = (n1-n2-another)+'0';

        another = 0;

        }

        else

        {

        result[cur_rs++] = (n1+10-n2-another)+ '0';

        another = 1;

        }

        }

        while(i >= 0)

        {

        n1 = str1[i--] - '0';

        if(another != 0)

        {

        n1 -= another;

        another = 0;

        }

        result[cur_rs++] = n1 + '0';

        }

        result[cur_rs] = '\0';

        cur_rs = remove_zero(result, cur_rs);

        if(flag)

        {

        result[cur_rs++] = '-';

        result[cur_rs] = '\0';

        }

        reverse(result, cur_rs);

        return cur_rs;

        }

        voidaddi(const char *num1, const char *num2, char *result)

        {

        int len1 = strlen(num1);

        int len2 = strlen(num2);

        int rs_len;

        if(!len1 || !len2)

        return;

        char str1[100], str2[100];

        strncpy(str1, num1, len1);

        str1[len1] = '\0';

        strncpy(str2, num2, len2);

        str2[len2] = '\0';

        if(str1[0] == '-' && str2[0] == '-')

        {

        move(str1, len1);

        move(str2, len2);

        rs_len = real_add(str1, str2, result, false);

        }else if(str1[0] == '-')

        {

        move(str1, len1);

        rs_len = real_minus(str2, str1, result);

        }

        else if(str2[0] == '-')

        {

        move(str2, len2);

        rs_len = real_minus(str1, str2, result);

        }else

        rs_len = real_add(str1, str2, result, true);

        }

        //int main(int argc, char *argv[])

        intmain()

        {

        char num1[100],num2[100];

        printf("請(qǐng)輸入兩個(gè)整型數(shù)據(jù):\n");

        scanf("%s%s",num1,num2);

        char result[100];

        memset(result, 0, 100);

        addi(num1,num2, result);

        printf("%s\n", result);

        return 0;

        }

        11. 描述:10個(gè)學(xué)生考完期末考試評(píng)卷完成后,A老師需要?jiǎng)澇黾案窬,要求如下:

        (1) 及格線是10的倍數(shù);

        (2) 保證至少有60%的學(xué)生及格;

        (3) 如果所有的學(xué)生都高于60分,則及格線為60分

        輸入:輸入10個(gè)整數(shù),取值0~100

        輸出:輸出及格線,10的倍數(shù)

        #include

        void bubblesort(int arr[])

        {

        inti,j,temp;

        for(i=0;i<10;i++)

        for(j=0;j<9-i&&arr[j]>arr[j+1];j++)

        {

        temp=arr[j];

        arr[j]=arr[j+1];

        arr[j+1]=temp;

        }

        }

        int GetPassLine(int a[])

        {

        bubblesort(a);

        if(a[0]>=60)

        return60;

        else

        return(((int)a[4]/10)*10);

        }

        main()

        {

        inta[10]={0};

        intresult;

        printf("請(qǐng)隨機(jī)輸入10個(gè)成績(jī)(0-100):\n");

        scanf("%d%d%d%d%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9]);

        printf("\n");

        result=GetPassLine(a);

        printf("及格線為:%d\n",result);

        return1;

        }

        12. 描述:一條長(zhǎng)廊里依次裝有n(1 ≤ n ≤ 65535)盞電燈,從頭到尾編號(hào)1、2、3、…n-1、n。每盞電燈由一個(gè)拉線開關(guān)控制。開始,電燈全部關(guān)著。

        有n個(gè)學(xué)生從長(zhǎng)廊穿過(guò)。第一個(gè)學(xué)生把號(hào)碼凡是1的倍數(shù)的電燈的開關(guān)拉一下;接著第二個(gè)學(xué)生把號(hào)碼凡是2的倍數(shù)的電燈的開關(guān)拉一下;接著第三個(gè)學(xué)生把號(hào)碼凡是3的倍數(shù)的電燈的開關(guān)拉一下;如此繼續(xù)下去,最后第n個(gè)學(xué)生把號(hào)碼凡是n的倍數(shù)的電燈的開關(guān)拉一下。n個(gè)學(xué)生按此規(guī)定走完后,長(zhǎng)廊里電燈有幾盞亮著。注:電燈數(shù)和學(xué)生數(shù)一致。

        輸入:電燈的數(shù)量

        輸出:亮著的電燈數(shù)量

        樣例輸入:3

        樣例輸出:1

        #include

        #define Max_Bubl_Num 65535

        int GetLightLampNum(int n)

        {

        intBublNum[Max_Bubl_Num]={0}; //0表示燈滅,1表示燈亮

        unsignedint i,j;

        unsignedint count=0;

        for(i=1;i<=n;i++)

        for(j=i;j<=n&&j%i==0;j++)

        {

        BublNum[j-1]+=1;

        BublNum[j-1]=BublNum[j-1]%2;

        }

        for(intk=0;k

        {

        if(BublNum[k]==1)

        count++;

        }

        returncount;

        }

        int main()

        {

        intn,result;

        printf("請(qǐng)輸入燈的數(shù)量(1-65535):\n");

        scanf("%d",&n);

        result=GetLightLampNum(n);

        printf("最后亮燈的數(shù)量為:%d\n",result);

        return0;

        }

        13. 描述:已知2條地鐵線路,其中A為環(huán)線,B為東西向線路,線路都是雙向的。經(jīng)過(guò)的站點(diǎn)名分別如下,兩條線交叉的換乘點(diǎn)用T1、T2表示。編寫程序,任意輸入兩個(gè)站點(diǎn)名稱,輸出乘坐地鐵最少需要經(jīng)過(guò)的車站數(shù)量(含輸入的起點(diǎn)和終點(diǎn),換乘站點(diǎn)只計(jì)算一次)。

        地鐵線A(環(huán)線)經(jīng)過(guò)車站:A1 A2 A3 A4 A5 A6A7 A8 A9 T1 A10 A11 A12 A13 T2 A14 A15 A16 A17 A18

        地鐵線B(直線)經(jīng)過(guò)車站:B1 B2 B3 B4 B5 T1B6 B7 B8 B9 B10 T2 B11 B12 B13 B14 B15

        輸入:輸入兩個(gè)不同的站名

        輸出:輸出最少經(jīng)過(guò)的站數(shù),含輸入的起點(diǎn)和終點(diǎn),換乘站點(diǎn)只計(jì)算一次

        輸入樣例:A1 A3

        輸出樣例:3

        #include

        #include

        #include

        #include

        using namespace std;

        #define MAX 35

        #define SUBWAY_A 20

        #define SUBWAY_B 15

        typedef struct node{

        int adjvex;

        struct node *next;

        }edgenode;

        typedef struct{

        char name[10];

        bool flag;

        edgenode *link;

        }vexnode;

        const charsubway_name1[SUBWAY_A][10]={"A1","A2","A3","A4","A5","A6","A7","A8","A9","T1","A10","A11","A12","A13","T2","A14","A15","A16","A17","A18"};

        const charsubway_name2[SUBWAY_B][10]={"B1","B2","B3","B4","B5","B6","B7","B8","B9","B10","B11","B12","B13","B14","B15"};

        void creat(vexnode ga[]){

        int i;

        edgenode *p;

        for(i=0;i

        ga[i].link=NULL;

        ga[i].flag=true;

        if(i

        elsestrcpy(ga[i].name,subway_name2[i-20]);

        }

        //A地鐵建鄰接表

        for(i=1;i

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=i-1;

        p->next=NULL;

        ga[i].link=p;

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=i+1;

        p->next=NULL;

        ga[i].link->next=p;

        if(i==9){

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=SUBWAY_A+4;

        p->next=NULL;

        ga[i].link->next->next=p;

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=SUBWAY_A+5;

        p->next=NULL;

        ga[i].link->next->next->next=p;

        }

        else if(i==14){

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=SUBWAY_A+9;

        p->next=NULL;

        ga[i].link->next->next=p;

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=SUBWAY_A+10;

        p->next=NULL;

        ga[i].link->next->next->next=p;

        }

        }

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=SUBWAY_A-1;

        p->next=NULL;

        ga[0].link=p;

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=1;

        p->next=NULL;

        ga[0].link->next=p;

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=SUBWAY_A-2;

        p->next=NULL;

        ga[SUBWAY_A-1].link=p;

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=0;

        p->next=NULL;

        ga[SUBWAY_A-1].link->next=p;

        //B地鐵建鄰接表

        for(i=1;i

        if(i==4||i==5||i==9||i==10)continue;

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=SUBWAY_A+i-1;

        p->next=NULL;

        ga[i+SUBWAY_A].link=p;

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=SUBWAY_A+i+1;

        p->next=NULL;

        ga[i+SUBWAY_A].link->next=p;

        }

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=SUBWAY_A+3;

        p->next=NULL;

        ga[SUBWAY_A+4].link=p;

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=9;

        p->next=NULL;

        ga[SUBWAY_A+4].link->next=p;

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=9;

        p->next=NULL;

      更多相關(guān)文章推薦閱讀:

      1.2016年華為認(rèn)證考試題庫(kù)

      2.2016年華為hcie認(rèn)證考試題庫(kù)

      3.2016年華為認(rèn)證認(rèn)證試題(筆試)

      4.2016年華為認(rèn)證考試題及答案

      5.2016年華為上機(jī)考試題

      6.2016年華為HCDA認(rèn)證考試題庫(kù)

      7.2016年華為筆試題及及答案

      8.2016年華為筆試面試題及答案

      9.2016年華為HCDA認(rèn)證考試筆試題及答案

        ga[SUBWAY_A+5].link=p;

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=SUBWAY_A+6;

        p->next=NULL;

        ga[SUBWAY_A+5].link->next=p;

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=SUBWAY_A+8;

        p->next=NULL;

        ga[SUBWAY_A+9].link=p;

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=14;

        p->next=NULL;

        ga[SUBWAY_A+9].link->next=p;

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=14;

        p->next=NULL;

        ga[SUBWAY_A+10].link=p;

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=SUBWAY_A+11;

        p->next=NULL;

        ga[SUBWAY_A+10].link->next=p;

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=SUBWAY_A+1;

        p->next=NULL;

        ga[SUBWAY_A].link=p;

        p=(edgenode*)malloc(sizeof(edgenode));

        p->adjvex=SUBWAY_A+SUBWAY_B-2;

        p->next=NULL;

        ga[SUBWAY_A+SUBWAY_B-1].link=p;

        // 打印各鄰接節(jié)點(diǎn)

        for(i=0;i

        printf("%s:",ga[i].name);

        edgenode *s;

        s=ga[i].link;

        while(s!=NULL){

        printf("->%s",ga[s->adjvex].name);

        s=s->next;

        }

        printf("\n");

        }

        }

        int main(){

        vexnode ga[MAX];

        creat(ga);

        int i;

        char str[2][10];

        while(scanf("%s%s",str[0],str[1])!=EOF){

        int temp=0;

        for(i=0;i

        ga[i].flag=true;

        if(!strcmp(str[0],ga[i].name))temp=i;

        }

        queueq;

        q.push(ga[temp]);

        ga[temp].flag=false;

        int count=0;

        int start=0;

        int end=1;

        bool find_flag=false;

        while(!q.empty()){

        if(find_flag) break;

        count++;

        printf("************************\n");

        printf("第%d層搜索:",count);

        int temp_end=end;

        while(start

        printf("%s",q.front().name);

        if(!strcmp(q.front().name,str[1])){

        find_flag=true;

        break;

        }

        edgenode *s;

        s=q.front().link;

        while(s!=NULL){

        if(ga[s->adjvex].flag){

        q.push(ga[s->adjvex]);

        ga[s->adjvex].flag=false;

        end++;

        //printf("%s ",ga[s->adjvex].name);

        }

        s=s->next;

        }

        q.pop();

        start++;

        }

        printf("\n");

        }

        printf("%d\n",count);

        }

        return 0;

        }

        14. 字串轉(zhuǎn)換

        問(wèn)題描述:

        將輸入的字符串(字符串僅包含小寫字母‘a’到‘z’),按照如下規(guī)則,循環(huán)轉(zhuǎn)換后輸出:a->b,b->c,…,y->z,z->a;若輸入的字符串連續(xù)出現(xiàn)兩個(gè)字母相同時(shí),后一個(gè)字母需要連續(xù)轉(zhuǎn)換2次。例如:aa 轉(zhuǎn)換為 bc,zz 轉(zhuǎn)換為 ab;當(dāng)連續(xù)相同字母超過(guò)兩個(gè)時(shí),第三個(gè)出現(xiàn)的字母按第一次出現(xiàn)算。

        要求實(shí)現(xiàn)函數(shù):

        void convert(char *input,char* output)

        【輸入】 char *input , 輸入的字符串

        【輸出】 char *output ,輸出的字符串

        【返回】 無(wú)

        #include

        #include

        #include

        void convert(char *input,char* output)

        {

        if(input==NULL)

        return;

        chartemp='\0';

        intlen_input=strlen(input);

        inti;

        intflag=0;

        for(i=0;i

        {

        if(input[i]!=temp)

        {

        output[i]=(input[i]-'a'+1)%26+'a';

        temp=input[i];

        flag=1;

        }

        else

        {

        if(flag==1)

        {

        output[i]=(input[i]-'a'+2)%26+'a';

        temp=input[i];

        flag=0;

        }

        else

        {

        output[i]=(input[i]-'a'+1)%26+'a';

        temp=input[i];

        flag=1;

        }

        }

        }

        output[i]='\0';

        }

        void main()

        {

        char*input="xyz";

        charoutput[256];

        // scanf("%s",input);

        convert(input,output);

        printf("%s\n",output);

        }

        15. 在給定字符串中找出單詞( “單詞”由大寫字母和小寫字母字符構(gòu)成,其他非字母字符視為單詞的間隔,如空格、問(wèn)號(hào)、數(shù)字等等;另外單個(gè)字母不算單詞);找到單詞后,按照長(zhǎng)度進(jìn)行降序排序,(排序時(shí)如果長(zhǎng)度相同,則按出現(xiàn)的順序進(jìn)行排列),然后輸出到一個(gè)新的字符串中;如果某個(gè)單詞重復(fù)出現(xiàn)多次,則只輸出一次;如果整個(gè)輸入的字符串中沒(méi)有找到單詞,請(qǐng)輸出空串。輸出的單詞之間使用一個(gè)“空格”隔開,最后一個(gè)單詞后不加空格。

        要求實(shí)現(xiàn)函數(shù):

        void my_word(charinput[], char output[])

        【輸入】 char input[], 輸入的字符串

        【輸出】 char output[],輸出的字符串

        【返回】 無(wú)

        #include

        #include

        #include

        void my_word(char input[],charoutput[])

        {

        char *p;

        char *temp;

        char *word[10];

        int len_input=strlen(input);

        int i,j;

        char except[] = ",";

        char *blank = " ";

        i=0;

        for (i=0;i

        {

        if (input[i]<'A' || (input[i]>'Z'&&input[i]<'a') ||input[i]>'z')

        {

        input[i]=',';

        }

        }

        j=0;

        /*保存取出的單詞*/

        p= strtok(input,except);

        while(NULL!=p)

        {

        word[j++]=p;

        p= strtok(NULL,except);

        }

        for(i=0;i<5;i++)

        printf("%s",word[i]);

        /*對(duì)單詞按照長(zhǎng)度降序排序,冒泡法*/

        for (i=0;i<5;i++)

        {

        for (j=1;j<5-i;j++)

        {

        if(strlen(word[j-1])

        {

        temp=word[j];

        word[j]=word[j-1];

        word[j-1]=temp;

        }

        }

        }

        /*刪除相同單詞*/

        for (i=0;i<5;i++)

        {

        for(j=i+1;j<5;j++)

        {

        if(strcmp(word[i],word[j])==0)

        word[j]="\0";

        }

        }

        /*將單詞連接起來(lái)輸出*/

        for (j=0;j<5;j++)

        {

        if (0==j)

        {

        strncpy(output,word[j],strlen(word[j])+1);

        }

        else

        {

        strcat(output,blank);

        strcat(output,word[j]);

        }

        }

        return ;

        }

        int main()

        {

        char input[] ="some local buses, some1234123drivers";

        printf("篩選之前的字符串:%s\n",input);

        char output[30];

        my_word(input,output);

        printf("篩選之后的字符串:%s",output);

        printf("\n");

        return 0;

        }

        16. 數(shù)組中數(shù)字都兩兩相同,只有一個(gè)不同,找出該數(shù)字:

        int findUnique(int* a, int len)

        {

        int i = 1;

        int temp =a[0];

        for(; i

        {

        temp= temp ^ a[i];

        }

        printf("%d", temp);

        }

        17.題目二:數(shù)組中數(shù)字兩兩相同,有兩個(gè)不同,找出這兩個(gè):

        #include

        int a[] = {1,1,2,4,3,3,2,5};

        int findXorSum(int* a, int len)

        {

        int i = 0;

        int temp =0;

        for(; i

        {

        temp= temp ^ a[i];

        }

        return temp;

        }

        int findFirstBit1(int n)

        {

        int count =1;

        while(!( n &1))

        {

        n =n>>1;

        count++;

        }

        returncount;

        }

        int isBit1(int a, int count)

        {

        a= a >> count-1;

        return(a & 1);

        }

        void findTwoUnique(int* a, int len)

        {

        int i = 0;

        int m = 0, n= 0;

        int temp =findXorSum(a, len);

        int count =findFirstBit1(temp);

        for(; i

        {

        if(isBit1(a[i],count))

        {

        m= m ^ a[i];

        }

        else

        {

        n= n ^ a[i];

        }

        }

        printf("%d,%d", m, n);

        }

        int main()

        {

        findTwoUnique(a,8);

        }

        18. 鏈表翻轉(zhuǎn)。給出一個(gè)鏈表和一個(gè)數(shù)k,比如鏈表1→2→3→4→5→6,k=2,則翻轉(zhuǎn)后2→1→4→3→6→5,若k=3,翻轉(zhuǎn)后3→2→1→6→5→4,若k=4,翻轉(zhuǎn)后4→3→2→1→5→6,用程序?qū)崿F(xiàn)

        思想:采用遍歷鏈表,分成length/k組,對(duì)每組進(jìn)行逆轉(zhuǎn),逆轉(zhuǎn)的同時(shí)要將逆轉(zhuǎn)后的尾和頭連接起來(lái)

      更多相關(guān)文章推薦閱讀:

      1.2016年華為認(rèn)證考試題庫(kù)

      2.2016年華為hcie認(rèn)證考試題庫(kù)

      3.2016年華為認(rèn)證認(rèn)證試題(筆試)

      4.2016年華為認(rèn)證考試題及答案

      5.2016年華為上機(jī)考試題

      6.2016年華為HCDA認(rèn)證考試題庫(kù)

      7.2016年華為筆試題及及答案

      8.2016年華為筆試面試題及答案

      9.2016年華為HCDA認(rèn)證考試筆試題及答案

        //#include "stdafx.h"

        #include "stdio.h"

        #include "stdlib.h"

        #include

        typedef struct Node{

        intvalue;

        Node*next;

        }LinkList;

        void Converse(LinkList* pPre,LinkList*pCur)

        { //鏈表逆轉(zhuǎn)

        LinkList*p = NULL;

        LinkList*pNext = NULL;

        p= pPre->next;

        LinkList*p1 = NULL;

        if(pCur!=NULL)

        pNext= pCur->next;

        while(p!=pNext)

        {

        p1= p->next;

        p->next= pPre;

        pPre= p;

        p= p1;

        }

        }

        int main()

        {

        intcount = 0, k,i=0,j=0,flag = 1,length=0,groups = 0;

        scanf("%d",&k);

        LinkList*pPre = (LinkList*)malloc(sizeof(LinkList));

        LinkList*pCur = (LinkList*)malloc(sizeof(LinkList));

        LinkList*pNext = (LinkList*)malloc(sizeof(LinkList));

        LinkList*head = NULL;

        LinkList* pTempTail = NULL; //指向逆轉(zhuǎn)之后的尾部

        LinkList*pTempHead = NULL;

        pCur->value= 1;

        pPre= pCur; //創(chuàng)建初始鏈表

        for(i=2;i<=6;i++){

        LinkList*node = (LinkList*)malloc(sizeof(LinkList));

        node->value= i;

        pCur->next= node;

        pCur= node;

        }

        pCur->next= NULL;//最后一定要置NULL,c++中用new則無(wú)須置NULL

        pCur= pPre;

        while(pCur!=NULL)

        {

        length++;

        pCur= pCur->next;

        }

        i=0;

        groups= length/k; //分成K段

        pCur= pPre;

        while(i<=groups)

        {

        count= 0;

        while(count

        {

        pCur= pCur->next;

        count++;

        }

        if(i

        {

        pNext= pCur->next;

        pTempHead= pCur; /*沒(méi)做翻轉(zhuǎn)之前的頭部,變成了翻轉(zhuǎn)之后的尾部*/

        if(flag== 0)

        {

        pTempTail->next= pTempHead;

        }

        pTempTail= pPre;

        Converse(pPre,pCur);

        //pTempTail= pPre;

        if(flag==1)

        {

        head= pCur;

        flag= 0;

        }

        pCur= pNext;

        }

        else

        {

        pTempTail->next= pNext;

        }

        pPre= pCur;

        i++;

        }

        pCur= head;

        while(j

        j++;

        printf("%d",pCur->value);

        pCur= pCur->next;

        }

        printf("\n");

        // system("pause");

        return0;

        }

        19. 鏈表相鄰元素翻轉(zhuǎn),如a->b->c->d->e->f-g,翻轉(zhuǎn)后變?yōu)椋篵->a->d->c->f->e->g

        #include

        #include

        #include

        typedef struct node{

        charval;

        structnode* pNext;

        }Node;

        Node* CreateList(int n);

        void Traverslist(Node* pHead);

        Node* TransNeighbor(Node* pHead);

        int main(){

        Node*pHead = CreateList(7);

        printf("beforetransform\n");

        Traverslist(pHead);

        TransNeighbor(pHead);

        printf("\naftertransform\n");

        Traverslist(pHead);

        getchar();

        return1;

        }

        //創(chuàng)建新鏈表

        Node* CreateList(int n){

        Node*pHead = (Node*)malloc(sizeof(Node));

        Node*pTail = pHead;

        pTail->pNext=NULL;

        inti;

        for(i=0;i < n; i++){

        Node* pNew = (Node*)malloc(sizeof(Node));

        pNew->val = 'a'+i;

        pTail->pNext = pNew;

        pNew->pNext = NULL;

        pTail = pNew;

        }

        returnpHead;

        }

        void Traverslist(Node* pHead){

        Node*p = pHead->pNext;

        intisFirst = 0;

        while(p!=NULL)

        {

        if(isFirst==0)

        {

        printf("%c",p->val);

        isFirst=1;

        }else{

        printf("->%c",p->val);

        }

        p= p->pNext;

        }

        return;

        }

        Node* TransNeighbor(Node* pHead){

        Node*p = pHead->pNext;

        while(p->pNext!=NULL &&p->pNext->pNext!=NULL)

        {

        charvalue = p->val;

        p->val=p->pNext->val;

        p->pNext->val=value;

        p=p->pNext->pNext;

        }

        returnpHead;

        }

        20. 輸入一串字符串,其中有普通的字符與括號(hào)組成(包括‘(’、‘)’、‘[’,']'),要求驗(yàn)證括號(hào)是否匹配,如果匹配則輸出0、否則輸出1.

        #include

        #include

        //#define MAX 100

        int main()

        {

        chara[100],c[]="(((1+2))";

        int i=0,j=0;;

        int flag=0;

        while(c[i]!=NULL&&flag==0)

        {

        switch(c[i])

        {

        case('('):

        case('['):

        a[j++]=c[i];break;

        case(')'):

        if(a[j-1]=='(')

        {

        a[j-1]='\0';

        j--;

        }

        else

        flag=1;

        break;

        case(']'):

        if(a[j-1]=='[')

        {

        a[j-1]='\0';

        j--;

        }

        else

        flag=1;

        break;

        }

        i++;

        }

        if(j!=0) flag=1;

        printf("%d\n",flag);

        return 0;

        }

        方法2:#include

        #include

        #include // !!!分配內(nèi)存頭文件

        #define m 20

        typedef char ElemType;

        typedef struct

        {

        ElemType stack[m];

        int top;

        }stacknode;

        stacknode *sp;

        Init(stacknode *st)

        {

        st->top=0;

        return 0;

        }

        void Push(stacknode *st,ElemType x)

        {

        if(st->top==m)

        printf("The stack isoverflow!\n");

        else

        {

        st->top=st->top+1;

        st->stack[st->top]=x;

        }

        }

        void Pop(stacknode *st)

        {

        st->top=st->top-1;

        }

        main()

        {

        char s[m]="(()";

        int i;

        printf("Creat astack!\n");

        sp = (stacknode*)malloc(sizeof(stacknode)); // !!!添加的語(yǔ)句

        Init(sp);

        printf("Input aexpression:\n");

        // gets(s);

        for(i=0;i

        {

        if(s[i]=='(')

        Push(sp,s[i]);

        if(s[i]==')')

        Pop(sp);

        }

        if(sp->top==0)

        printf("左右括號(hào)是匹配的!\n");

        else

        printf("左右括號(hào)是不匹配的!\n");

        return 0;

        }

        21.將第一行中含有第二行中“23”的數(shù)輸出并排序

        2.輸入一行數(shù)字:123 423 5645 875 186523

        在輸入第二行:23

        將第一行中含有第二行中“23”的數(shù)輸出并排序

        結(jié)果即:123 423 186523

        #include

        #define M 20

        int main()

        {

        int a[M];

        int i,j,s,temp;

        int sort[M],t=0;

        char c=' ';

        i=0;

        while(c!='\n')

        {

        scanf("%d%c",&temp,&c);

        a[i++]=temp;

        }

        scanf("%d",&s);

        for(j=0;j

        {

        temp=a[j];

        if(temp%100==s)

        {

        sort[t++]=a[j];

        }

        else

        temp/=10;

        }

        for(i=0;i

        for(j=0;j

        {

        if(sort[j]>sort[j+1])

        {

        temp=sort[j+1];

        sort[j+1]=sort[j];

        sort[j]=temp;

        }

        }

        for(i=0;i

        printf("%d",sort[i]);

        printf("\n");

        return 0;

        }

        22輸入m個(gè)字符串 和一個(gè)整數(shù)n, 把字符串M化成以N為單位的段,不足的位數(shù)用0補(bǔ)齊。

        如 n=8 m=9 ,

        123456789劃分為:12345678

        90000000

        123化為 :12300000

        #include

        #include

        int main()

        {

        char c[200]={'\0'};

        scanf("%s",&c);

        int n,i,j;

        int len=strlen(c);

        scanf("%d",&n);

        for(i=1;i<=len;i++)

        {

        j=i%n;

        printf("%c",c[i-1]);

        if(j==0)

        printf("\n");

        }

        if(j!=0)

        for(i=j+1;i<=n;i++)

      更多相關(guān)文章推薦閱讀:

      1.2016年華為認(rèn)證考試題庫(kù)

      2.2016年華為hcie認(rèn)證考試題庫(kù)

      3.2016年華為認(rèn)證認(rèn)證試題(筆試)

      4.2016年華為認(rèn)證考試題及答案

      5.2016年華為上機(jī)考試題

      6.2016年華為HCDA認(rèn)證考試題庫(kù)

      7.2016年華為筆試題及及答案

      8.2016年華為筆試面試題及答案

      9.2016年華為HCDA認(rèn)證考試筆試題及答案

        printf("0");

        return 0;

        }

        23將 電話號(hào)碼 one two 。。。nine zero

        翻譯成1 2 。。9 0

        中間會(huì)有double

        例如輸入:OneTwoThree

        輸出:123

        輸入:OneTwoDoubleTwo

        輸出:1222

        輸入:1Two2 輸出:ERROR

        輸入:DoubleDoubleTwo 輸出:ERROR

        有空格,非法字符,兩個(gè)Double相連,Double位于最后一個(gè)單詞都錯(cuò)誤

        #include

        #include

        #include

        int main()

        {

        chara[11][11]={"zero","one","two","three","four","five","six","seven","eight","nine","double"};

        char temp[11], c=' ';

        int i,j,f,d=0;

        while(c!='\n')

        {

        scanf("%s%c",&temp,&c);

        f=0;

        for(j=0;j<11;j++)

        {

        if(!strcmp(temp,a[j])&&j<10)

        {

        printf("%d",j);

        f=1;

        if(d==1)

        {

        printf("%d",j);

        d=0;

        }

        }

        elseif(!strcmp(temp,a[j])&&j==10)

        {

        d=1;

        f=1;

        }

        }

        if(f==0)

        break;

        }

        if(d==1||f==0)

        printf("error\n");

        printf("\n");

        return 0;

        }

        24.將整數(shù)倒序輸出,剔除重復(fù)數(shù)據(jù)

        輸入一個(gè)整數(shù),如12336544,或1750,然后從最后一位開始倒過(guò)來(lái)輸出,最后如果是0,則不輸出,輸出的數(shù)字是不帶重復(fù)數(shù)字的,所以上面的輸出是456321和571。如果是負(fù)數(shù),比如輸入-175,輸出-571。

        #include

        #include

        #include

        #include

        int main()

        {

        char*input=(char*)malloc(sizeof(char));

        scanf("%s",input);

        inta[10]={0},i,flag=0,flag1=0;

        int len=strlen(input);

        if(input[0]=='-')

        {

        flag=1;

        for(i=0;i

        input[i]=input[i+1];

        }

        intlen1=strlen(input);

        int n[50],temp;

        int count=0;

        for(i=0;i

        {

        temp=input[i]-'0';

        if(a[temp]==0)

        {

        n[count++]=temp;

        a[temp]=1;

        }

        }

        n[count]='\0';

        if(flag==1)

        printf("-");

        for(intii=count-1;ii>=0;ii--)

        {

        if(n[ii]!=0||flag1!=0)

        {

        printf("%d",n[ii]);

        flag1=1;

        }

        }

        printf("\n");

        return 0;

        }

        25.編程的時(shí)候,if條件里面的“(”、“)”括號(hào)經(jīng)常出現(xiàn)不匹配的情況導(dǎo)致編譯不過(guò),請(qǐng)編寫程序檢測(cè)輸入一行if語(yǔ)句中的圓括號(hào)是否匹配正確。同時(shí)輸出語(yǔ)句中出現(xiàn)的左括號(hào)和右括號(hào)數(shù)量,如if((a==1)&&(b==1))是正確的,而if((a==1))&&(b==1))是錯(cuò)誤的。注意if語(yǔ)句的最外面至少有一對(duì)括號(hào)。提示:用堆棧來(lái)做。

        輸入:if((a==1)&&(b==1))

        輸出:RIGTH 3 3

        輸入:if((a==1))&&(b==1))

        輸出:WRONG 3 4

        #include

        #include

        int main()

        {

        char s[800]={'\0'};

        scanf("%s",&s);

        // char s[]="if(())";

        int len=strlen(s);

        int i,left=0,right=0;

        int a[50],k=0,flag=1;

        for(i=0;i

        {

        if(s[i]=='(')

        {

        left++;

        a[k]=1;

        k++;

        }

        elseif(s[i]==')')

        {

        right++;

        if(a[k-1]==1&&k>0)

        {

        a[k-1]=0;

        k--;

        }

        else

        flag=0;

        }

        if((i==2&&s[i]!='(')||(i==len-1&&s[i]!=')'))

        flag=0;

        }

        if(a[0]==0&&flag!=0)

        printf("RIGHT");

        else

        printf("WRONG");

        printf("%d%d\n",left,right);

        return 0;

        }

        約瑟夫問(wèn)題

        輸入一個(gè)由隨機(jī)數(shù)組成的數(shù)列(數(shù)列中每個(gè)數(shù)均是大于0的整數(shù),長(zhǎng)度已知),和初始計(jì)數(shù)值m。從數(shù)列首位置開始計(jì)數(shù),計(jì)數(shù)到m后,將數(shù)列該位置數(shù)值替換計(jì)數(shù)值m,并將數(shù)列該位置數(shù)值出列,然后從下一位置從新開始計(jì)數(shù),直到數(shù)列所有數(shù)值出列為止。如果計(jì)數(shù)到達(dá)數(shù)列尾段,則返回?cái)?shù)列首位置繼續(xù)計(jì)數(shù)。請(qǐng)編程實(shí)現(xiàn)上述計(jì)數(shù)過(guò)程,同時(shí)輸出數(shù)值出列的順序

        比如:輸入的隨機(jī)數(shù)列為:3,1,2,4,初始計(jì)數(shù)值m=7,從數(shù)列首位置開始計(jì)數(shù)(數(shù)值3所在位置)

        第一輪計(jì)數(shù)出列數(shù)字為2,計(jì)數(shù)值更新m=2,出列后數(shù)列為3,1,4,從數(shù)值4所在位置從新開始計(jì)數(shù)

        第二輪計(jì)數(shù)出列數(shù)字為3,計(jì)數(shù)值更新m=3,出列后數(shù)列為1,4,從數(shù)值1所在位置開始計(jì)數(shù)

        第三輪計(jì)數(shù)出列數(shù)字為1,計(jì)數(shù)值更新m=1,出列后數(shù)列為4,從數(shù)值4所在位置開始計(jì)數(shù)

        最后一輪計(jì)數(shù)出列數(shù)字為4,計(jì)數(shù)過(guò)程完成。

        輸出數(shù)值出列順序?yàn)椋?,3,1,4。

        要求實(shí)現(xiàn)函數(shù):

        void array_iterate(int len, int input_array[], int m, int output_array[])

        【輸入】 int len:輸入數(shù)列的長(zhǎng)度;

        int intput_array[]:輸入的初始數(shù)列

        int m:初始計(jì)數(shù)值

        【輸出】 int output_array[]:輸出的數(shù)值出列順序

        【返回】 無(wú)

        示例:

        輸入:int input_array[] = {3,1,2,4},int len = 4, m=7

        輸出:output_array[] = {2,3,1,4}

        解題思路:

        每次出列一個(gè)數(shù)值,需要對(duì)m、input_array、output_array、輸出位置outPos、起始位置startPos進(jìn)行更新;

        對(duì)于輸出位置outPos的計(jì)算是關(guān)鍵!通過(guò)分析可知,outPos=(startPos+m-1)%num

        代碼實(shí)現(xiàn):

        view plaincopy to clipboardprint?

        #include

        voidprint_array(int len, int array[])

        {

        for(int i=0; i

        printf("%d ", array[i]);

        printf("\n");

        }

        //input_array:a[0]...a[len-1]

        voidarray_iterate(int len, int input_array[], int m, int output_array[])

        {

        int startPos=0;

        int outPos;

        int nIter=len-1;

        int num=len;

        for(; nIter>=0; nIter--)

        {

        outPos=(m+startPos-1)%num;

        m=input_array[outPos];

        startPos=outPos;

        printf("outPos is %d, new m is%d\n", outPos, m);

        output_array[len-nIter-1]=input_array[outPos];

        for(int i=outPos; i

        input_array[i]=input_array[i+1];

        num--;

        print_array(num, input_array);

        }

        }

        voidmain()

        {

        int input_array[]={3,1,2,4};

        int output_array[4]={0};

        array_iterate(4, input_array, 7,output_array);

        print_array(4, output_array);

        }

        27.統(tǒng)計(jì)數(shù)字出現(xiàn)的次數(shù),最大次數(shù)的統(tǒng)計(jì)出來(lái)

        舉例:

        輸入:323324423343

        輸出:3,6

        #include

        #include

        #include

        int main()

        {

        char*num="323324423343";

        inta[10]={0};

        intlen=strlen(num);

        inti,j,temp,count=0,maxnum=0;

        printf("%d\n",len);

        for(i=0;i

        {

        temp=num[i]-'0';

        a[temp]++;

        }

        inttemp1=a[0];

        for(j=0;j<10;j++)

        {

        if(a[j]!=0)

        {

        count++;

        temp1=(temp1>a[j])?temp1:a[j];

        printf("%d%d\n",a[j],j);

        }

        }

        printf("數(shù)字出現(xiàn)次數(shù)為:%d\n",count);

        printf("最大次數(shù)為:%d\n",temp1);

        return0;

        }

        28. .字符串首字母轉(zhuǎn)換成大寫

        舉例:

        輸入:this is a book

        返回:This Is A Book

        #include

        #include

        #include

        int main()

        {

        charinput[]="this is a book";

        charoutput[256]={'\0'};

        int i,len;

        len=strlen(input);

        printf("變換前的字符串為:%s\n",input);

        for(i=0;i

        {

        if(input[0]!='')

        input[0]-=32;

        if(input[i]=='')

        input[i+1]-=32;

        output[i]=input[i];

        }

        printf("變換后的字符串為:%s\n",output);

        }

        29. 子串分離

        題目描述:

        通過(guò)鍵盤輸入任意一個(gè)字符串序列,字符串可能包含多個(gè)子串,子串以空格分隔。請(qǐng)編寫一

        個(gè)程序,自動(dòng)分離出各個(gè)子串,并使用’,’將其分隔,并且在最后也補(bǔ)充一個(gè)’,’并將子

        串存儲(chǔ)。

        如果輸入“abc def gh i d”,結(jié)果將是abc,def,gh,i,d,

        要求實(shí)現(xiàn)函數(shù):

        voidDivideString(const char *pInputStr, long lInputLen, char *pOutputStr);

        【輸入】 pInputStr: 輸入字符串

        lInputLen: 輸入字符串長(zhǎng)度

        【輸出】 pOutputStr: 輸出字符串,空間已經(jīng)開辟好,與輸入字符串等長(zhǎng);

        #include

        #include

        #include

        #include

      更多相關(guān)文章推薦閱讀:

      1.2016年華為認(rèn)證考試題庫(kù)

      2.2016年華為hcie認(rèn)證考試題庫(kù)

      3.2016年華為認(rèn)證認(rèn)證試題(筆試)

      4.2016年華為認(rèn)證考試題及答案

      5.2016年華為上機(jī)考試題

      6.2016年華為HCDA認(rèn)證考試題庫(kù)

      7.2016年華為筆試題及及答案

      8.2016年華為筆試面試題及答案

      9.2016年華為HCDA認(rèn)證考試筆試題及答案

        void DivideString(const char *pInputStr, long lInputLen, char*pOutputStr)

        {

        int cnt;

        const char*p=pInputStr;

        while(*p!=NULL)

        {

        if(*p!=' ')

        { cnt = 0;

        *pOutputStr++ = *p++;

        }

        else

        { cnt++;

        p++;

        if(cnt==1)

        *pOutputStr++ = ',';

        }

        }

        *pOutputStr++ = ',';

        *pOutputStr = '\0';

        }

        void main()

        {

        char *str = "abcdef gh i d";

        long len =strlen(str);

        char *outstr =(char*)malloc(sizeof(str));

        //char outstr[100];

        DivideString(str,len,outstr);

        printf("%s",outstr);

        printf("\n");

        }
       

      更多相關(guān)文章推薦閱讀:

      1.2016年華為認(rèn)證考試題庫(kù)

      2.2016年華為hcie認(rèn)證考試題庫(kù)

      3.2016年華為認(rèn)證認(rèn)證試題(筆試)

      4.2016年華為認(rèn)證考試題及答案

      5.2016年華為上機(jī)考試題

      6.2016年華為HCDA認(rèn)證考試題庫(kù)

      7.2016年華為筆試題及及答案

      8.2016年華為筆試面試題及答案

      9.2016年華為HCDA認(rèn)證考試筆試題及答案

      【華為認(rèn)證考試題庫(kù)】相關(guān)文章:

      華為認(rèn)證考試簡(jiǎn)介09-22

      華為認(rèn)證考試地址07-26

      2016年華為HCDA認(rèn)證考試題庫(kù)07-16

      2016年華為hcie認(rèn)證考試題庫(kù)06-29

      華為認(rèn)證HCIE考試心得06-25

      華為HCIE認(rèn)證考試流程06-23

      華為認(rèn)證:HCNA考試心得09-20

      華為Enterprise Communication認(rèn)證考試大綱05-30

      華為認(rèn)證考試報(bào)名流程10-13

      主站蜘蛛池模板: 蜜臀av一区二区三区人妻在线| 国产在线看不卡一区二区| 国产美女久久久亚洲综合| 国产成年无码久久久久下载| 中文字幕亚洲综合久久| 无码久久精品蜜桃| 日韩精品有码在线视频| 西丰县| 蓬溪县| 日韩午夜在线视频观看| 国产高清白浆| 国产白浆美女在线观看| 中文字幕亚洲第一页在线| 日韩精品一区二区三区四区视频 | 无码国产精品一区二区免费式芒果| 南木林县| 亚洲精品久久久中文字| 国产成人精品人人做人人爽| 国产亚洲美女精品久久久2020| 久久99老妇伦国产熟女高清| 久久久精品人妻一区二| 久久国产成人高清精品亚洲| 宅男久久精品国产亚洲av麻豆| 国产高跟黑色丝袜在线| 国产经典免费视频在线观看| 辽宁省| 国产激情视频在线| а的天堂网最新版在线| 加勒比在线一区二区三区| 密云县| 国产福利一区二区三区视频在线看| 大白屁股流白浆一区二区三区| 欧美日一本| 免费人成视频欧美| 91中文人妻丝袜乱一区三区| 国产盗摄老熟女视频一区二区三区| 久久人妻少妇精品系列| 日本中文字幕一区二区在线观看 | av乱色熟女一区二区三区| 国内精品人人妻少妇视频| 日本亚洲一级中文字幕|