-
Notifications
You must be signed in to change notification settings - Fork 1
/
Masuratori eronate.cpp
58 lines (42 loc) · 1.04 KB
/
Masuratori eronate.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main(){
int n,nr,cnt=0,e=0;
double medie=1,deviatie=1,suma=0,suma2=0,diferenta=0;
vector<int>vec;
cin>>n;
for(int i=0;i<n;i++){
cin>>nr;
vec.push_back(nr);
}
diferenta=vec[0];
do{
for(int i=0;i<vec.size();i++){
suma+=vec[i];
}
medie=suma/vec.size();
suma=0;
for(int i=0;i<vec.size();i++){
suma2+=(vec[i]-medie)*(vec[i]-medie);
}
deviatie=sqrt(suma2/vec.size());
suma2=0;
diferenta=abs(medie-vec[0]);
for(int i=0;i<vec.size();i++){
if ( abs ( medie - vec[i] ) > abs ( diferenta ) ){
diferenta = abs(medie-vec[i]);
e=i;
}
//cout<<diferenta<<' ';
}
//cout<<endl;
diferenta=abs(medie-vec[0]);
if(deviatie/medie>0.1){
cnt++;
vec.erase(vec.begin()+e);
}
}while(deviatie/medie>0.1);
cout<<cnt;
}