-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayerwithmostaverage.cpp
More file actions
53 lines (51 loc) · 1022 Bytes
/
Copy pathplayerwithmostaverage.cpp
File metadata and controls
53 lines (51 loc) · 1022 Bytes
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
#include <iostream>
using namespace std;
struct player
{
char name[15];
int score;
int innings;
int alive;
float avg;
};
void input(player *P , int n)
{
for(int i=0;i<n;i++)
{
cout<<"Enter name-score-innings-not out"<<endl;
cin>>P[i].name>>P[i].score>>P[i].innings>>P[i].alive;
if(P[i].alive>P[i].innings)
{
cout<<"Impossible";
P[i].avg=0;
}
else
{
P[i].avg=(float)P[i].score / (P[i].innings-P[i].alive);
}
}
}
void display (player *P,int n)
{
for(int i=0;i<n;i++)
{
if(P[i].avg>50)
{
cout<<P[i].name<<"With average"<<P[i].avg;
}
else
{
cout<<"Below Average"<<P[i].avg<<endl;
}
}
}
int main()
{
int n;
cout<<"Enter the number of players range = undr 10"<<endl;
cin>>n;
player P[10];
input(P,n);
display(P,n);
return 0;
}