迴圈

輸入數字

先印出整數部分

在印出小數部分(長除法)

輸出

 

 

#include<iostream>

 

 

using namespace std;

int main()
{
    int a,b, N, remainder;

    while(cin >> a >> b >> N)
    {
        cout << a/b << ".";

        remainder = a%b*10;
        for(int i = 0; i<N; i++, remainder = remainder%b * 10)
            cout << remainder/b;

        cout << endl;
    }

    return 0;
}

arrow
arrow
    全站熱搜

    大神(偽) 發表在 痞客邦 留言(0) 人氣()