Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <math.h>
- #include <iomanip>
- #include <ctime>
- using namespace std;
- const int M = 100; //MAXIMUM
- void Init(double P[], int N)
- {
- srand(time(0));
- for(int i=0; i<N; i++)
- {
- P[i] = rand() % M;
- }
- }
- void Tisk(double P[], int N)
- {
- for(int j=0; j<N; j++)
- {
- cout<<setfill(' ')<<setw(3)<<j<<"=";
- cout<<setfill(' ')<<setw(5)<<P[j];
- cout<<endl;
- }
- cout<<endl;
- }
- double Alfa(double P[], int N)
- {
- double Min=M,Max=0;
- for(int j=0; j<N; j++)
- {
- if(P[j]>Max) Max=P[j];
- if(P[j]<Min) Min=P[j];
- }
- return sqrt((Max-Min)*(Max-Min));
- }
- void Filtr(double P[], int N, double O)
- {
- for(int j=0; j<N; j++)
- {
- P[j]=P[j]-O;
- }
- }
- int main()
- {
- const int N = 8;
- double P[N];
- Init(P,N);
- cout<<"Nahodne hodnoty: "<<endl<<endl;
- Tisk(P,N);
- double O=Alfa(P,N);
- cout<<endl<<"Parametr filtru: "<<O<<endl<<endl<<endl;
- Filtr(P,N,O);
- cout<<"Vyfiltrovane hodnoty: "<<endl<<endl;
- Tisk(P,N);
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment