0

我一直在这里绞尽脑汁:

cout << orig << " * " << count << endl;
string check = multiply2(orig, count);
cout << "Check was: " << check << " and number is: " << number << endl;
cout << "the compare result: " << check.compare(number) <<  endl;
if(check.compare(number) == 0)
{
  cout << "wahoo it matches!!! we did it! " << endl;
}
else
{
  cout << "Doesnt Match " << endl;
}

我希望它能够匹配并打印wahoo it matches!!! we did it!,但它却说它不匹配。

这是我的输出:

1 * 900000
Check was: 900000 and number is: 90000
the compare result: 1
Doesnt Match

任何人都知道他们为什么不匹配?

4

1 回答 1

6

您比较900000(如 9E5)与90000(如 9E4)。电脑是对的。

于 2013-01-18T21:47:37.857 回答