• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆 - 505  文章 - 1034  trackbacks - 0
            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567


            子曾經曰過:編程無他,唯手熟爾!

            常用鏈接

            留言簿(94)

            隨筆分類(649)

            隨筆檔案(505)

            相冊

            BCB

            Crytek

            • crymod
            • Crytek's Offical Modding Portal

            Game Industry

            OGRE

            other

            Programmers

            Qt

            WOW Stuff

            搜索

            •  

            積分與排名

            • 積分 - 912174
            • 排名 - 14

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

            華為招聘--C語言筆試試題

            一、判斷題(對的寫T,錯的寫F并說明原因,每小題4分,共20分)
            1、有數組定義int a[2][2]={{1},{2,3}};則a[0][1]的值為0。(     )
            2、int (*ptr) (),則ptr是一維數組的名字。(     )
            3、指針在任何情況下都可進行>,<,>=,<=,==運算。(     )
            4、switch(c) 語句中c可以是int ,long,char ,float ,unsigned int 類型。(   )
            5、#define print(x)  printf("the no, "#x",is ")
             
            二、填空題(共30分)
            1、在windows下,寫出運行結果,每空2分,共10分。
            char str[ ]= "Hello";
            char *p=str;
            int n=10;
            sizeof(str)=(      )
            sizeof(p)=(       )
            sizeof(n)=(       )
            void func(char str[100])
            {    }
            sizeof(str)=(     )
             
            2、void setmemory(char **p, int num)
            { *p=(char *) malloc(num);}
            void test(void)
            {  char *str=NULL;
               getmemory(&str,100);
               strcpy(str,"hello");
               printf(str);
            }
            運行test函數有什么結果?(                                )10分
             
            3、設int arr[]={6,7,8,9,10};
                 int *ptr=arr;
               *(ptr++)+=123;
             printf("%d,%d",*ptr,*(++ptr));
            (                                   ) 10分
             
            二、編程題(第一小題20,第二小題30分)
            1、  不使用庫函數,編寫函數int strcmp(char  *source, char *dest)
            相等返回0,不等返回-1;
             2、  寫一函數int fun(char *p)判斷一字符串是否為回文,是返回1,不是返回0,出錯返回-1
            五、 閱讀程序題(每個小題5分,共20分)
            1.閱讀以下程序,概括地寫出程序的功能。
            #i nclude
            double Exp(double x)
            { double sum=1.0;
            double term=x;
            double i=1 ;
            while (term>=1.0E-8)
            { sum+=term ;
            i++;
            term=term*x/i ;
            }
            return sum ;
            }
            void main()
            { double s;
            s=Exp(1.0)+Exp(2.0);
            cout.precision(8);
            cout<<"s="<<
            }
            2. 閱讀程序,寫出程序執行時輸出結果。
            #i nclude
            const int SIZE=10;
            class stack
            { char stck[SIZE];
            int top;
            public:
            void init();
            void push(char ch);
            char pop();
            };
            void stack::init()
            { top=0; }
            void stack::push(char ch)
            { if(top==SIZE)
             { cout<<"Stack is full.\n";
            return ;
             }
            stck[top++]=ch;
            }
            char stack::pop()
            { if(top==0)
               { cout<<"Stack is empty.\n";
               return 0;
            }
            return stck[--top];
            }
            void main()
            { stack s1, s2;
             s1.init();
             s2.init();
             s1.push('a');
             s1.push('b');
             s1.push('c');
             s2.push('x');
             s2.push('y');
             s2.push('z');
             for(int i=0; i<3; i++)
            cout<<"Pop s1:"<<
             for(i=0; i<3; i++)
            cout<<"Pop s2:"<<
            }
            程序結果:
            3.閱讀程序,寫出程序運行時輸出結果。
            #i nclude
            class Tdate
            { public:
            Tdate();
            Tdate(int d);
            Tdate(int m, int d);
            Tdate(int m, int d, int y);
            protected:
            int month;
            int day;
            int year;
            };
            Tdate::Tdate()
            { month=4;
               day=15;
               year=1995;
            cout<<<"/" <<<"/" <<
            }
            Tdate::Tdate(int d)
            { month=4;
               day=d;
              year=1996;
            cout<<<"/" <<<"/" <<
            }
            Tdate::Tdate(int m, int d)
            { month=m;
               day=d;
               year=1997;
            cout<<<"/" <<<"/" <<
            }
            Tdate::Tdate(int m, int d, int y)
            { month=m;
               day=d;
               year=y;
            cout<<<"/" <<<"/" <<
            }
            void main()
            { Tdate aday;
            Tdate bday(10);
            Tdate cday(2,12);
            Tdate dday(1,2,1998);
            }
            運行結果:
            4.閱讀程序,寫出程序運行時輸出結果。
            #i nclude
            #i nclude
            class shape
            { public:
            shape(double x, double y):xCoord(x), yCoord(y){}
            virtual double Area()const {return 0.0; }
            protected:
            double xCoord, yCoord;
            };
            class AA :public shape
            { public:
            AA(double x, double y, double r): shape(x,y), rad(r){}
            virtual double Area()const { return 3.0 * rad * rad; }
            protected:
            double rad;
            };
            class BB :public shape
            { public:
            BB(double x1, double y1, double x2, double y2)
            :shape(x1, y1), x2Coord(x2), y2Coord(y2){ }
            virtual double Area()const;
            protected:
            double x2Coord, y2Coord;
            };
            double BB:Area()const
            { return fabs((xCoord-x2Coord)* (yCoord - y2Coord));
            //庫函數fabs(double t)求得t的絕對值
            }
            void fun(const shape& sp)
            { cout<<
            }
            void main()
            { AA aa(2.0, 5.0, 4.0);
            fun(aa);
            BB bb(2.0, 8.0, 12.0, 17.0);
            fun(bb);
            }
            運行結果:
            六、 編寫程序題(每小題10分,共20分)
            1.編寫一個函數int Judge(int *pArray, int n),判斷一個n×n二維整數數組pArray 是否為“魔方陣”,若是返回1,否則返回0。所謂魔方陣就是將1到n2的各個數字組成的方陣,它的每一行、每一列以及兩個對角線上數字之和均相等。例如,3×3的中,A是魔方陣,而B不是魔方陣。然后在主程序中調用Judge函數判斷數組A是否為魔方陣。
            參考程序
            #i nclude
            int Judge(int *pArray, int n)
            { int s1, s2, s3,s4,sum=0;
            int *p=pArray;
            for(int i=1; i<= n*n; i++)
            { int Found=0; //為0,不在方陣中;
            for(int j=0; j
            if(p[j]==i)
            { Found=1; //為1,在方陣中
            break;
            }
            if(Found==0) return 0; // 值為 i 的元素不在數組中,顯然不是魔方陣
            }
            for( i=1; i<=n*n; i++)
            sum=sum+i;
            sum=sum / n; // 各行、各列、對角線元素應當得到的和
            s3=0;
            s4=0;
            for( i=0; i
            { s1=0, s2=0;
            p=pArray;
            for(int j=0; j
            { s1=s1+p[i*n+j]; //第i行的元素和
             s2=s2+p[j*n+i]; //第i列的元素和
            }
            if ( s1!=sum)
            return 0;
            if ( s2!=sum)
            return 0;
            s3=s3+pArray[i*n+i];     // 對角線一元素和
            s4=s4+pArray[i*n+(n-1-i)]; // 對角線二元素和
            }
            if(s3!=sum)
            return 0;
            if(s4 != sum)
            return 0;
            return 1;
            }
            void main()
            { int Array[3][3]={{ 8, 1, 6},{ 3, 5, 7},{ 4, 9, 2}};
            當 x 輸入值為9999時,函數返回值為多少?
            int fun ( unsigned int x )
            { int count = 0;
            while(x)
            {
            x = x & (x-1);
            count++;
            }
            return count;
            }
            答案:此函數是在計算 x 中含有1的個數,所以返回值為8。
            if(Judge((int*)Array, 3))
            cout<<"Yes, it's a magic array"<
            else
            cout<<"No, it isn't a magic array"<
            }
            /*********************************
            * 兩個超大數相乘算法
            *********************************/
            #i nclude
            void main()
            {
            int a[30],b[30],c[60];
            int i,j;
            /* 給乘數和被乘數賦值,并把結果賦零 */
            for (i=0;i<30;i++)
            {
            a[i]=i%10;
            b[i]=i%10;
            c[2*i]=0;
            c[2*i+1]=0;
            }
            /* 給每位結果賦值,這里應該考慮清楚為什么這么寫
            還有這里的位的值的最大限度應該是-128 -- +127
            所以就算是10*10也可以滿足存進去一個char類型里 */
            for(i=0;i<30;i++)
            for(j=0;j<30;j++)
            c[i+j]+=a[i]*b[j];
            /* 這里把每個位>10的數進位和把余數重新賦值給這一位 */
            for(i=0;i<59;i++)
            {
            c[i+1]+=c[i]/10;
            c[i]=c[i]%10;
            }
            /* 打印出來 */
            for(i=0;i<30;i++)
            printf("%d",a[30-i-1]);
            printf("\n");
            for(i=0;i<30;i++)
            printf("%d",b[30-i-1]);
            printf("\n");
            for(i=0;i<60;i++)
            printf("%d",c[60-i-1]);
            printf("\n");
            }
            posted on 2007-10-18 00:58 七星重劍 閱讀(1621) 評論(1)  編輯 收藏 引用 所屬分類: 面試筆試

            FeedBack:
            # re: 做筆試題增長功力(3)--華為 2007-10-18 19:22 螞蟻終結者
            華為的筆試題貌似不難么,呵呵  回復  更多評論
              
            日韩精品久久久肉伦网站| 国产 亚洲 欧美 另类 久久| 久久精品一区二区| 久久亚洲精品成人AV| 久久只有这里有精品4| 精品久久久久久久久久中文字幕 | 国产精品久久精品| 日韩久久久久久中文人妻 | 久久久久久精品久久久久| 久久99精品免费一区二区| 久久福利青草精品资源站| 狠狠狠色丁香婷婷综合久久俺| 99国产欧美精品久久久蜜芽| 999久久久免费精品国产| 久久精品国产清高在天天线| 久久精品国产99久久无毒不卡| 五月丁香综合激情六月久久| 久久精品国产亚洲AV无码偷窥| 久久AV高清无码| 狠狠精品干练久久久无码中文字幕| 天天综合久久久网| 人人狠狠综合久久亚洲| 欧美日韩精品久久久久| 久久天天躁狠狠躁夜夜avapp| 久久精品国产亚洲av水果派| 99久久国产热无码精品免费久久久久| 日韩精品国产自在久久现线拍| 久久国产视频99电影| 一本久久a久久精品亚洲| 国产精品一区二区久久| 欧美久久一级内射wwwwww.| 97精品国产97久久久久久免费| av无码久久久久不卡免费网站| 精品欧美一区二区三区久久久| 中文精品久久久久人妻| 久久综合久久自在自线精品自 | 国内精品伊人久久久久影院对白| 亚洲国产成人精品久久久国产成人一区二区三区综 | 国产99久久精品一区二区| 久久精品国产WWW456C0M| 亚洲∧v久久久无码精品|