-
Notifications
You must be signed in to change notification settings - Fork 1
/
Structure Example.cpp
103 lines (98 loc) · 1.75 KB
/
Structure Example.cpp
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
100
101
102
103
// mehmet karakose
#include <string>
#include <string.h>
#include <fstream>
#include <iostream>
#include <string.h>
using namespace std;
struct playerInfo
{
string name;
string surname;
double goals;
int assists;
double shots;
double shooting;
int points;
}p[8];
void readPlayer()
{
ifstream input;
ofstream output;
input.open("players.txt");
for(int i=0;i<8;i++)
{
input>>p[i].name;
input>>p[i].surname;
input>>p[i].goals;
input>>p[i].assists;
//input>>p[i].points;
input>>p[i].shots;
//input>>p[i].shooting;
if(input.eof())
{
break;}
}
input.close();
}
void displayPlayer()
{
cout<<"Name ";
cout<<"Surname ";
cout<<"Goals ";
cout<<"Assists ";
cout<<"Points ";
cout<<"Shots ";
cout<<"Shooting"<<endl;
for(int i=0;i<8;i++)
{
cout<<p[i].name<<" ";
cout<<p[i].surname<<" ";
cout<<p[i].goals<<" ";
cout<<p[i].assists<<" ";
cout<<p[i].points<<" ";
cout<<p[i].shots<<" ";
cout<<p[i].shooting<<" "<< endl;
}
}
void calculatedValues()
{
for(int i=0;i<8;i++)
{
p[i].points=p[i].goals+p[i].assists;
p[i].shooting=(p[i].goals)/((p[i].shots)*100);
}
}
void savePlayer()
{
ofstream output;
output.open("teams.txt");
for(int i=0;i<8;i++)
{
output<<p[i].name<<" ";
output<<p[i].surname<<" ";
output<<p[i].goals<<" ";
output<<p[i].assists<<" ";
output<<p[i].points<<" ";
output<<p[i].shots<<" ";
output<<p[i].shooting<<" "<< endl;
}
output.close();
}
int main()
{
ifstream input;
ofstream output;
input.open("players.txt");
if(input.eof())
{
cout<<"yanlış oldu";
}else{
readPlayer();
}
calculatedValues();
savePlayer();
displayPlayer();
system("PAUSE");
return 0;
}