0
我想在C++書中做下列任務。奇怪的十六進制答案簡單的數學代碼::塊
運行此之後:
#include <iostream>
using namespace std;
int main()
{
double first_arg;
double second_arg;
cout << "Enter first argument: ";
cin >> first_arg;
cout << "Enter second argument: ";
cin >> second_arg;
cout << first_arg << " * " << second_arg << " = "
<< cout << first_arg * second_arg << "\n";
cout << first_arg << " + " << second_arg << " = "
<< cout << first_arg + second_arg << "\n";
cout << first_arg << "/" << second_arg << " = "
<< cout << first_arg/second_arg << "\n";
cout << first_arg << " - " << second_arg << " = "
<< cout << first_arg - second_arg << "\n";
我得到一些意想不到的結果。這樣的結果直接從Windows的命令行復制:
Enter first argument: 7
Enter second argument: 9
7 * 9 = 0x6fcc43c463
7 + 9 = 0x6fcc43c416
7/9 = 0x6fcc43c40
7 - 9 = 0x6fcc43c4-2
我使用的是最新版本的默認編譯器設置代碼塊的。謝謝。
有趣。我從來沒有做過「cout」,並且從來沒有預料到它會打印出這樣的結果。 –
哈哈!非常感謝,男士!我不知道我怎麼沒看到:s –
奇怪的十六進制數的解釋可以在http://stackoverflow.com/questions/10987156/does-stdcout-have-a-return-value – Ritesh