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

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

      時間:2023-03-31 22:35:05 筆試題目 我要投稿
      • 相關推薦

      華為招聘-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");
      }

      【華為招聘-C語言筆試試題】相關文章:

      華為C語言筆試題12-12

      華為筆試題(C語言)12-10

      華為筆試題及分析目(C語言篇)11-06

      華為技術招聘筆試題總結03-25

      華為技術招聘筆試題總結07-31

      yahoo在線筆試題(c語言)12-12

      C語言筆試試題及答案07-31

      c語言筆試題目及答案08-17

      基礎C++/C語言筆試題分享11-21

      2015C語言筆試題及答案08-08

      主站蜘蛛池模板: 国产精品久久久亚洲第一牛牛 | 国产成人久久精品亚洲小说| 郯城县| 视频网站在线观看不卡| 国产粉嫩高清| 蜜桃一区二区三区在线看| 湘潭市| 潞西市| 湘西| 午夜无码无遮挡在线视频| 日本免费播放一区二区三区视频| 一级二级三一片内射视频在线 | 精品一二区| 偷拍网日本一区二区三区| 久热爱精品视频在线观看久爱| 少妇久久久被弄到高潮| 山西省| 久久精品成人亚洲另类欧美| 精品国产1区2区3区AV| 少妇高潮无码自拍| 久久亚洲日本免费高清一区| 久久精品国产一区二区涩涩| 国产日韩AV无码免费一区二区| 免费国产一级片内射老| 亚洲午夜久久久久中文字幕久| 亚洲国产成人精品激情| 林甸县| 日本高清在线播放一区二区三区| 新余市| 亚洲AV永久无码精品表情包| 巴彦县| 精品人妻一区二区久久| 加勒比精品一区二区三区| 国产精品专区一区二区av免费看 | 色综合久久久久综合一本到桃花网| 日本一区二区国产高清在线播放| 亚洲中文字幕无码不卡电影 | 精品人妻av区乱码| 天堂AV无码AV毛片毛| 一本色道久久综合亚洲精| 午夜福利不卡无码视频|