How to keep any digit after the decimal point

#include<iostream>
#include<cstring>
#include<cmath>
#define pi 3.14159265
using namespace std;
int main()
{
 char format[10]={0};
 int t;
 cin>>t;
 while(t- -)
 {
  long long n,x;
  scanf("%lld%lld",&n,&x);//Find n to the Pi power, and output x digits after the decimal point
  sprintf(format,"%%.%dlf", x);
  double ans;
  ans=1.0*pow(n,pi);
  printf(format,ans);
  cout<<endl;
 }
 return 0;
 }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325378739&siteId=291194637