PPS校园招聘笔试真题(4)

招聘笔试题2018-11-22才子老师

  {

  return number[i];

  }

  bitset<128>::reference operator[](size_t i)

  {

  return number[i];

  }

  friend bool operator<(int128 const& i1,int128 const& i2)

  {

  return i1.number < i2.number;

  }

  friend int128 operator+(int128 const& i1,int128 const& i2)

  {

  if(i1 == 0)

  return i2;

  if(i2 == 0)

  return i1;

  int128 result;

  bitset<2> sum;

  for(int i = 0 ; i < 128 ; ++i)

  {

  sum=i1[i]+i2[i]+sum.to_ulong();

  result[i]=sum[0];

  sum>>=1;

  }

  return result;

  }

  friend int128 operator-(int128 const& i1,int128 const& i2)

  {

  if(i2==0)

  return i1;

  int128 result=i1;

  for(int i = 0 ; i < 128 ; ++i)

  {

  if(i2[i] == 0) {}

  else

  {

  if(result[i] == 1)

相关推荐

猜你喜欢

大家正在看

换一换