-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