我一直在看互聯網上的YouTube和不同的指南,並認爲這將是一個有趣的計算器,因爲我看過很多人這樣做,這是我開始。它工作正常,但我希望它也能夠顯示小數。所有的答案表示讚賞。 (我有一大堆的#include,但忽略這些)我如何讓它顯示小數
#include <iostream>
#include <limits>
#include <cstdio>
#include <tchar.h>
#include <conio.h>
using namespace std;
int main()
{
std::cout << "My first caclulator\nPlease enter your first number: ";
int x, y;
std::cin >> x;
std::cout << "Please enter the other number: ";
std::cin >> y;
int w = x*y;
int c = x + y;
int v = x - y;
int q = x/y;
std::cout << "\nNumbers multiplied: " << w << endl;
std::cout << "\nNumbers added together: " << c << endl;
std::cout << "\nNumbers subtracted: " << v << endl;
std::cout << "\nNumbers divided: " << q << endl;
_tprintf(_T("Press any key to exit "));
while (_kbhit()) _gettch();
_gettch();
return 0;
}
閱讀「int」和「float」或「double」類型之間的區別。 – DevilaN
你的代碼並不[標準C++中的](http://coliru.stacked-crooked.com/a/4ad8de13d5963f13)。 – user0042