/*现有16枚外形相同的硬币,其中有一枚比真币的重量轻的假币, 若采用分治法找出这枚假币,至少比较多少次才能够找出该假币*/ #include using namespace std; //我们假设16枚硬币的编号为0~15 int num=0; int weight(int a[],int start,int end) { int sum=0; for(int i=start;i<=end;i++) sum+=a[i]; return sum; } void findFalseCoin(int a[],int low,int high,int &coin) { int partion; partion=(low+high)/2; coin=partion; num++; if(low

相关文章:

  • 2021-05-29
  • 2021-07-26
  • 2021-07-31
  • 2021-11-27
  • 2021-12-15
  • 2022-12-23
  • 2021-09-09
猜你喜欢
  • 2022-12-23
  • 2021-08-28
  • 2022-12-23
  • 2021-09-05
  • 2022-03-09
  • 2022-02-27
  • 2021-06-08
相关资源
相似解决方案