Home > Back-end >  Such as: c beginners, the problem of calculating mean square deviation, compile and run error
Such as: c beginners, the problem of calculating mean square deviation, compile and run error

Time:09-27

O guide






 
#include
#include
Using namespace STD.
Void input (int n, int a []);
Double aver (int n, int a []);
Double stddev (int n, int a []);
Int main ()
{
Int a [100]={0};
int n;
Double business=0;
Double stdev=0;
Cout & lt; Stdev=stddev (n, a);
Cout & lt; <"Mean square error is:" & lt; return 0;
}
Void input (int n, int a [])
{
int i;
Cout & lt; <"Please input array elements:" & lt; <'/n';
For (I=0; i {
Cin & gt;> A, [I].
}
}
Double aver (int n, int a [])
{
double sum=0;
Double aver1=0;
int i;
For (I=0; i The sum +=a [I];
Aver1=sum/n * 1.0;
Return aver1;
}
Double stddev (int n, int a [])
{
double sum=0;
Double item=0;
Double D=0;
int i;
For (I=0; i {
The sum +=a [I];
Item +=pow (a [I] - sum/n, 2);
}
D=SQRT (item/n);
Return D;
}



Results:

CodePudding user response:

 cout & lt; <"Please input array elements:" & lt; <'\ n'; 

CodePudding user response:

Cout & lt; <"Please input array elements:" & lt; '/n';
STD: : endl is not sweet, you use this?

CodePudding user response:

reference 1/f, the wise know already should good karma response:
 cout & lt; <"Please input array elements:" & lt; <'\ n'; 

Thanks, errors have been found
  • Related