Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float sed(int a[],int z, int x)
- {
- int b=0;
- float suma=0;
- float srednia;
- int y = -1;
- for (int i = 0; i < z; i++)
- {
- a[i] = rand() % 90 + 10;
- }
- for (int j = 0; j < z; j++)
- {
- for (int i = 0; i < z-1; i++)
- {
- if (a[i] > a[i + 1])
- {
- b = a[i];
- a[i] = a[i + 1];
- a[i + 1] = b;
- }
- }
- }
- for (int i = x+1; i < z - x; i++)
- {
- suma = suma + a[i];
- }
- srednia= suma / (z-(2*x));
- if (z - (2 * x) > 0)
- {
- return srednia;
- }
- else
- {
- return y;
- }
- }
- void kolos1()
- {
- int a[20];
- int z;
- int x;
- //sed(a, 20, 3);
- printf("%f\n", sed(a, 20, 3));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement