-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmedian.c
101 lines (80 loc) · 1.84 KB
/
median.c
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
float median7(float yy,float kaa, float koo, float nee, float vii, float kuu,float see)
{
float array[7]; float tmp;
int i,j;
array[0]=yy; array[1]=kaa; array[2]=koo; array[3]=nee; array[4]=vii;
array[5]=kuu; array[6]=see;
for(j=0;j<7-1;j++)
for(i=0;i<7-1-j;i++){
if(array[i]>array[i+1]) {
tmp=array[i];
array[i] = array[i+1];
array[i+1]=tmp;
}
}
return(array[3]);
}
float median6(float yy,float kaa, float koo, float nee, float vii, float kuu)
{
float array[6]; float tmp;
int i,j;
array[0]=yy; array[1]=kaa; array[2]=koo; array[3]=nee; array[4]=vii;
array[5]=kuu;
for(j=0;j<6-1;j++)
for(i=0;i<6-1-j;i++){
if(array[i]>array[i+1]) {
tmp=array[i];
array[i] = array[i+1];
array[i+1]=tmp;
}
}
return(array[3]);
}
float median5(float yy,float kaa, float koo, float nee, float vii)
{
float array[5]; float tmp;
int i,j;
array[0]=yy; array[1]=kaa; array[2]=koo; array[3]=nee; array[4]=vii;
for(j=0;j<5-1;j++)
for(i=0;i<5-1-j;i++){
if(array[i]>array[i+1]) {
tmp=array[i];
array[i] = array[i+1];
array[i+1]=tmp;
}
}
return(array[2]);
}
float median4(float yy,float kaa, float koo, float nee)
{
float array[4]; float tmp;
int i,j;
array[0]=yy; array[1]=kaa; array[2]=koo; array[3]=nee;
for(j=0;j<4-1;j++)
for(i=0;i<4-1-j;i++){
if(array[i]>array[i+1]) {
tmp=array[i];
array[i] = array[i+1];
array[i+1]=tmp;
}
}
return(array[2]);
}
float median3(float yy,float kaa, float koo)
{
float array[3]; float tmp;
int i,j;
array[0]=yy; array[1]=kaa; array[2]=koo;
for(j=0;j<3-1;j++)
for(i=0;i<3-1-j;i++){
if(array[i]>array[i+1]) {
tmp=array[i];
array[i] = array[i+1];
array[i+1]=tmp;
}
}
return(array[1]);
}