对于控制位数输出

第一行是一个整数t,表示测试实例的个数;
然后是t行输入数据,每行包含两个正整数n和x,表示底数和保留位数。
(1 <= t <= 100,1 <= n <= 500,1 <= x <= 6)
a=n π(n的π次方)
#include<bits/stdc++.h>
using namespace std;
int main()
{
    const double pi=acos(-1.0);
    //cout<<pi<<endl;
    int T;
    cin>>T;
    while(T--)
    {
        int n,x;
        cin>>n>>x;
        //cout<<fixed<<setprecision(x)<<pow(1.0*n,pi)<<endl;//c++比较简单的输出
        printf("%.*f\n",x,pow(n,pi));//c语言输出

    }
    return 0;
}

通过一题增加的知识点

猜你喜欢

转载自blog.csdn.net/wchenchen0/article/details/80256888