-1
我想编写一个计算面积和体积以及给定数字的平均值的程序。我成功完成了这些工作,但是当我尝试计算标准偏差时我不知道如何解决,我甚至couldn`t明白究竟是什么问题,所以作为我的最后的手段,我请你们help.Thanks这里是我的代码Ubuntu C编程预期的浮点数,但参数类型为double *
#include <stdio.h>
#include <math.h>
int squaresarea(int edge)
{
int area = edge * edge;
printf ("Area of the square : %d\n",area);
return 0;
}
int rectanglesarea(int edge1,int edge2)
{
int rectanglesarea = edge1 * edge2;
printf ("Area of the rectangle : %d\n",rectanglesarea);
}
float spheresvolume(int radius)
{
float spheresvolume = (4.0/3)*M_PI*radius*radius*radius;
printf("Volume of the sphere: %f\n",spheresvolume);
}
float cylindersvolume(float radius1,float height)
{
float cylindersvolume = M_PI*radius1*radius1*height;
printf("Volume of the cylinder %f\n",cylindersvolume);
}
double average(float edge,float edge1,float edge2,float radius,float radius1,float height)
{
double average = (edge + edge1 + edge2 + radius + radius1 + height)/6;
printf("Average of the values entered: %f\n",average);
}
double standarddeviation(int edge,float average)
{
double standarddeviation = (edge - average);
}
int main (int edge,int edge1,int edge2,int radius,int radius1,int height)
{
printf("Enter the length of your square`s edge: ");
scanf("%d",&edge);
squaresarea(edge);
printf("Enter the lengths of your rectangles edges:");
scanf("%d %d",&edge1,&edge2);
rectanglesarea(edge1,edge2);
printf("Enter radius of your sphere: ");
scanf("%d",&radius);
spheresvolume(radius);
printf("Enter radius and height of your cylinder: ");
scanf("%d %d",&radius1,&height);
cylindersvolume(radius1,height);
average(edge,edge1,edge2,radius,radius1,height);
standarddeviation(edge,average);
return 0;
}
这里的错误是错误我得到:
错误是因为名称必须是唯一的。你有一个函数和一个名为'standarddeviation'的变量。您的代码中还存在更多问题:http://ideone.com/I7nSJJ – mch
请将您的错误消息作为文本发布。还有你的代码中有太多的错误。尝试使用'-Wall'编译它。 – deniss
所以我必须将其中的函数standarddeviation改为其他东西? – mamikun