Skip to content

小數點後幾位

a862. 2. My Dear Friend VIR

https://zerojudge.tw/ShowProblem?problemid=a862

有兩個方法:
cout<<fixed<<setprecision(小數點後幾位)<<數字<<endl;
printf("%.4位數\n", 變數);

#include<bits/stdc++.h>
using namespace std;
#define nn "\n"

int main(){

    double n,m;
    while(cin>>n>>m){
        int h=1000;
        cout<<fixed<<setprecision(4)<<n/m*h<<endl;
    }
}
#include<bits/stdc++.h>
using namespace std;
#define nn "\n"

int main(){

    double n,m;
    while(cin>>n>>m){
        int h=1000;
        printf("%.4f\n", n/m*h);
    }
}