以小数点后取6位为例
方法一:
scanf("%d%d",&a,&b);
double num = a * pi + 2 * b;
printf("%.6lf
",num - 0.0000005);
方法二:转为字符串
int a,b;
char an[100];
scanf("%d%d",&a,&b);
double num = a * pi + 2 * b;
sprintf(an,"%.9lf",num);
for(i = 0;i < 100;i ++)
if(an[i] == '.')
break;
an[i + 7] = ' ';
printf("%s
",an);
方法三:转为整型
int a,b;
scanf("%d%d",&a,&b);
double num = a * pi + 2 * b;
int index = num * 1e6;
num = index / 1e6;
printf("%.6lf
",num);