السلام عليكم
رجاء الرد بأسرع وقت ممكن
بدي برنامج المطلوب منو كالتالي
برنامج وظيفتو يحسب المتوسط الحسابي (mean) لعناصر المصفوفة
و كذلك الانحراف المعياري standard deviation
مع مراعاة ان الناتج لازم يكون float
المتوسط الحابي = مجموع الارقام / عددها
الانحراف المعياري = الجذر التربيعي(( (العنصر - المتوسط الحسابي)^2)/عدد العناصر - 1)
the number of integer in the array is up to 100 but input will be determine when reading the number 100
your program should contain 4 functions:
1. function (readArray) that reads a set on integer value and stors them into on array.
2. function (meanArray) that calculate and return the mean of the input array.
3. function (standardDeviation) that calculate and returns the standard deviation on the input array.
4. function prints the input array ,its mean,and its standard deviation .م
و هادا حلي
#include<iostream>
#include<cmath>
using namespace std;
void readArray(int[],int);
void printArray(int a[],int size,float m,float s);
float meanArray(int[],int);
float standardDeviation(int[],int);
int main()
{
float mean,S;
const int size=100;
int arr;
readArray(arr,size);
mean=meanArray(arr,size);
S=standardDeviation(arr,size);
printArray(arr,size,mean,S);
system("pause");
return 0;
}
// read function
void readArray(int a[],int size)
{
for(int i=0;i<size;i++)
{
cout<<"arr["<<i+1<<"] = ";
cin>>a;
if(a==-1000)
break;
}
}
// mean function
float meanArray(int a[],int)
{
int size;
float total=0;
cout<<"enter number of array item";
cin>>size;
for(int i=0;i<size;i++)
total+=a;
return total/size;
}
// standard deviation
float standardDeviation(int a[],int)
{
int size;
float sum=0;
cout<<"enter number of array item";
cin>>size;
for(int i=0;i<size;i++)
sum+=a;
float avg;
avg=float(sum/size);
float n;
double result;
float total=0.0;
for(int i=0;i<size;i++)
{
n=float(a)-avg;
total+=(n*n);
}
int S;
S=sqrt(double(total/size-1));
return S;
}
// print function
void printArray(int a[],int size,float m,float s)
{
cout<<"enter number of array item";
cin>>size;
for(int i=0;i<size;i++)
cout<<a<<endl;
cout<<m<<" "<<s;
}