[英]I don't know how to output files and create additional programs
I wanted to make the following program, so I made it halfway, but I don't know how to make it from there.我想制作以下程序,所以我做了一半,但我不知道如何从那里制作。 I will give you the result you want to execute and the result of the current execution.我会给你你想要执行的结果和当前执行的结果。 Where should I edit?我应该在哪里编辑? want to execute.想执行。
Please enter three values:
5.0 9.0 -6.5
Average: 2.500
Original data: +5.000 +9.000 -6.500
Data after average deduction: +2.500 +6.500 -9.000
now to execute.现在执行。
Please enter three values:
5.0 9.0 -6.5
Average:2.500
Original data:5.000 9.000 -6.500
Data after average deduction:2.500 6.500 -9.000
source来源
#include <stdio.h>
double ave3 (double, double, double);
double subave3 (double *, double *, double *);
int main ()
{
double a, b, c, ave;
printf ("Please enter three values: \n");
scanf ("%lf%lf%lf", &a, &b, &c);
ave = ave3 (a, b, c); /* Function call */
printf ("Average:%.3f \n", ave);
printf ("Original data:%.3f %.3f %.3f \n", a, b, c);
subave3 (&a, &b, &c);
printf ("Data after average deduction:%.3f %.3f %.3f \n", a, b, c);
return 0;
}
/* A function that calculates the average. It also subtracts the average value from the data. */
double subave3 (double *x, double *y, double *z)
{
double ave = ave3(*x,*y,*z);
*x-= ave; /* Subtract the average from each data */
*y-= ave;
*z-= ave;
}
double ave3 (double x, double y, double z) {
double ave = (x + y + z) / 3.0;
return ave;
}
I think you can add +
like this:我认为您可以像这样添加+
:
printf ("Original data:%+.3f %+.3f %+.3f \n", a, b, c);
...
printf ("Data after average deduction:%+.3f %+.3f %+.3f \n", a, b, c);
When you'd run this, you would get this output:当你运行它时,你会得到这个输出:
src : $ ./a.out
Please enter three values:
5.0 9.0 -6.5
Average:2.500
Original data:+5.000 +9.000 -6.500
Data after average deduction:+2.500 +6.500 -9.000
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.