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. 創(chuàng)新工場筆試算法題附答案

        時間:2022-11-16 18:10:00 面試筆試 我要投稿
        • 相關推薦

        創(chuàng)新工場2014筆試算法題匯總附答案

           1. 編程實現(xiàn)堆排序

        創(chuàng)新工場2014筆試算法題匯總附答案

          #include

          usingnamespace std;

          void SwapValue(int &m, int &n)

          {

          int temp = m;

          m = n;

          n = temp;

          }

          void max_heap(vector &vec, int i, int heap_size)

          {

          int l = 2*i;

          int r = 2*i+1;

          int largest = i;

          if(l<=heap_size && vec[l-1]>vec[largest-1])

          largest = l;

          if(r<=heap_size && vec[r-1]>vec[largest-1])

          largest = r;

          if(largest!=i)

          {

          SwapValue(vec[largest-1],vec[i-1]);

          max_heap(vec, largest, heap_size);

          }

          }

          void heapSort(vector &vec)

          {

          int heap_size = vec.size();

          for(int i=heap_size/2; i>=1; i–)

          max_heap(vec, i, heap_size);

          for(int i=heap_size; i>=1; i–)

          {

          SwapValue(vec[0],vec[i-1]);

          max_heap(vec, 1, i);

          }

          }

          void print(vector vec)

          {

          for(int i=0; i

          cout<

          cout<

          }

          int main()

          {

          vector vec;

          vec.push_back(23);

          vec.push_back(5);

          vec.push_back(1);

          vec.push_back(10);

          vec.push_back(13);

          vec.push_back(32);

          vec.push_back(21);

          vec.push_back(14);

          vec.push_back(19);

          vec.push_back(20);

          cout<<“排序前: “<

          print(vec);

          heapSort(vec);

          cout<<“排序后: “<

          print(vec);

          return 0;

          }

          2.求一個正整數(shù)N的開方,要求不能用庫函數(shù)sqrt(),結(jié)果的精度在0.001

          解析:牛頓迭代

          #include

          using namespace std;

          int main()

          {

          int N;

          cout<<“輸入N的值:“;

          cin>>N

          double x1 = 1;//初值

          double x2 = x1/2.0+N/2.0/x1;

          while( fabs(x2-x1)>0.001)

          {

          x1 = x2;

          x2 = x1/2.0+N/2.0/x1;

          }

          cout<

          return 0;

          }

          3.給定一個矩陣intmaxtrixA[m][n],每行和每列都是增序的,實現(xiàn)一個算法去找矩陣中的某個元素element.

          解法一:

          #include

          using namespace std;

          const int M = 4;

          const int N = 4;

          int main

          {

          int matrix[M][N] = {};

          double element;

          int flag = 1;

          for(int j=0; j

          {

          if(matrix[i][j] == element)

          cout<<“位置“<

          while( flag

          –flag;

          while( flagelement )

          ++flag;

          }

          }

          解法二:

          bool Find(int *matrixA, int m, int n, int element)

          {

          bool found = false;

          if(matrixA != NULL & m & n)

          {

          int i,j;

          i=0;j=n-1;

          while(i

          {

          if(maxtrixA[i*n+j] == element)

          {

          found = true;

          break;

          }

          else if(matrix[i*n+j]>element

          –j;

          else

          ++i

          }

          }

          }

        【創(chuàng)新工場筆試算法題附答案】相關文章:

        創(chuàng)新工場現(xiàn)場筆試試題08-10

        創(chuàng)新工場筆試題2014年校園招聘08-10

        面試筆試題目規(guī)律題及答案08-01

        微軟面試算法題08-09

        java筆試題及答案07-28

        oracle筆試題及答案08-16

        求職面試試題50題(附標準答案)(1)07-31

        人事專員筆試題及答案08-16

        2017華為筆試題及答案08-07

        經(jīng)典java筆試題及答案分享08-10

        国产高潮无套免费视频_久久九九兔免费精品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>