-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplhw.c
More file actions
45 lines (44 loc) · 1.12 KB
/
splhw.c
File metadata and controls
45 lines (44 loc) · 1.12 KB
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
#include<stdio.h>
#include<math.h>
struct cricketer{
char name[50];
long long int score[5];
};
int main()
{
struct cricketer cricketer1,cricketer2;
scanf("%s",cricketer1.name);
int i;
double sum = 0,temp=0;
for(i=0;i<5;i++){
scanf("%lld",&cricketer1.score[i]);
sum = sum + cricketer1.score[i];
}
sum = sum/5;
for(i=0;i<5;i++){
temp = temp + (sum-cricketer1.score[i])*(sum-cricketer1.score[i]);
}
temp = sqrt(temp/4);
scanf("%s",cricketer2.name);
sum = 0;
double temp2=0;
for(i=0;i<5;i++){
scanf("%lld",&cricketer2.score[i]);
sum = sum + cricketer2.score[i];
}
sum = sum/5;
for(i=0;i<5;i++){
temp2 = temp2 + (sum-cricketer2.score[i])*(sum-cricketer2.score[i]);
}
temp2 = sqrt(temp2/4);
if(temp>temp2){
printf("More consistant player is %s",cricketer2.name);
}
else if(temp<temp2){
printf("More consistant player is %s",cricketer1.name);
}
else{
printf("Both cricketer are equally consistant");
}
return 0;
}