在C++中用於將浮點型數據轉換爲整型的不同技術有哪些?C++浮點型到整數型轉換
#include<iostream>
using namespace std;
struct database
{
int id,age;
float salary;
};
int main()
{
struct database employee;
employee.id=1;
employee.age=23;
employee.salary=45678.90;
/*
How can i print this value as an integer
(with out changing the salary data type in the declaration part) ?
*/
cout<<endl<<employee.id<<endl<<employee.age<<endl<<employee.salary<<endl;
return 0;
}
HTTP://www.cs.tut。fi /〜jkorpela/round.html – 2010-03-30 10:27:18