圆周率

 1 #include <iostream>
 2 #include <algorithm>
 3 using namespace std;
 4 
 5 int main(){
 6     int n, a, b;
 7     while (cin >> a >> b >> n){
 8         int Integer = a / b;
 9         cout << Integer << ".";
10         int Re = a%b;
11         for (int i = 0; i < n; i++){
12             if (Re != 0){
13                 a = Re * 10;
14                 Integer = a / b;
15                 cout << Integer;
16                 Re = a%b;
17             }
18             else
19                 cout << "0";
20         }
21         cout << endl;
22     }
23     //system("pause");
24     return 0;
25 }

 

posted @ 2018-03-06 19:30  ouyang_wsgwz  阅读(140)  评论(0编辑  收藏  举报