6-10

 1 #include <iostream>
 2 
 3 using namespace std;
 4 
 5 void splitFloat(float x,int * intPart,float * fracPart)
 6 {
 7     *intPart=static_cast<int>(x);
 8     *fracPart=x-*intPart;
 9 }
10 
11 
12 int main()
13 {
14     cout<<"Enter 3 float point numbers:"<<endl;
15     for(int i=0;i<3;i++)
16     {
17         float x,f;
18         int n;
19         cin>>x;
20         splitFloat(x,&n,&f);
21         cout<<"Inter Part="<<n<<"Fraction Part="<<f<<endl;
22     }
23     return 0;
24 }

 

posted @ 2013-11-02 15:13  退之  阅读(165)  评论(0编辑  收藏  举报