1. 程式人生 > >c++ int型和double型運算

c++ int型和double型運算

 

 

#include<iostream>
using namespace std;
int main()
{
	int a, b;
	a=3;
	b=4;
	cout<<"a/b ="<<a/b<<endl;
	cout<<"double(a/b) ="<<double(a/b)<<endl;
	cout<<"double(a)/b ="<<double(a)/b<<endl;
	cout<<"a/double(b) ="<<a/double(b)<<endl;
	if (a>0.5*b)
	{
		cout<<a<<endl;
	}

}

執行結果