forked from wenkai-Y/student-management-system
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Data_Analysis .h
255 lines (246 loc) · 4.91 KB
/
Data_Analysis .h
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#pragma once
#include <iostream>
#include <stdio.h>
#include "_StuIno_.h"
#include "Files_Processing.h"
using namespace std;
/*****全班平均分并输出*****/
double Class_Average(struct Student* ptr, int people)
{
double ave = 0;
for (int i = 0; i < people; ++i)
{
ave += ptr[i].ave;
}
return (ave / people);
}
/*****各科平均分*****/
void Subject_Average(struct Student* ptr, int people, double grade[3][3])
{
for (int i = 0; i < people; ++i)
{
grade[0][2] += ptr[i].math;
grade[1][2] += ptr[i].english;
grade[2][2] += ptr[i].computers;
}
grade[0][2] /= people;
grade[1][2] /= people;
grade[2][2] /= people;
}
/*****各科最大最小分数*****/
void find_max_min(struct Student* ptr, int people, double grade[3][3])
{
for (int i = 1; i < people; ++i)
{
grade[0][0] = ptr[0].math;
grade[0][1] = ptr[0].math;
grade[1][0] = ptr[0].english;
grade[1][1] = ptr[0].english;
grade[2][0] = ptr[0].computers;
grade[2][1] = ptr[0].computers;
if (grade[0][0] < ptr[i].math)
grade[0][0] = ptr[i].math;
if (grade[0][1] > ptr[i].math)
grade[0][1] = ptr[i].math;
if (grade[1][0] < ptr[i].english)
grade[1][0] = ptr[i].english;
if (grade[1][1] > ptr[i].english)
grade[1][1] = ptr[i].english;
if (grade[2][0] < ptr[i].computers)
grade[2][0] = ptr[i].computers;
if (grade[2][1] > ptr[i].computers)
grade[2][1] = ptr[i].computers;
}
}
/*****默认分析分数段人数*****/
void fenshuduan_1(struct Student* ptr, int people, int shufen[3][4])
{
for (int i = 0; i < people; ++i)
{
if (ptr[i].math >= 85)
++shufen[0][0];
else
if (ptr[i].math >= 60)
++shufen[0][1];
else
if (ptr[i].math >= 45)
++shufen[0][2];
else
if (ptr[i].math < 45)
++shufen[0][3];
if (ptr[i].english >= 85)
++shufen[1][0];
else
if (ptr[i].english >= 60)
++shufen[1][1];
else
if (ptr[i].english >= 45)
++shufen[1][2];
else
if (ptr[i].english < 45)
++shufen[1][3];
if (ptr[i].computers >= 85)
++shufen[2][0];
else
if (ptr[i].computers >= 60)
++shufen[2][1];
else
if (ptr[i].computers >= 45)
++shufen[2][2];
else
if (ptr[i].computers < 45)
++shufen[2][3];
}
}
/*****自义定分析分数段人数*****/
void zidingyifenshu(struct Student* ptr, int people, double ptr_[2], int renshu[3])
{
for (int i = 0; i < people; ++i)
{
if (ptr[i].math <= ptr_[0] && ptr[i].math >= ptr_[1])
++renshu[0];
if (ptr[i].english <= ptr_[0] && ptr[i].english >= ptr_[1])
++renshu[1];
if (ptr[i].computers <= ptr_[0] && ptr[i].computers >= ptr_[1])
++renshu[2];
}
}
/*****高数排名*****/
int mathrank(struct Student* ptr, int peoples, string number)
{
struct Student temp;
//冒泡排序
for (int i = 0; i < peoples - 1; ++i)
{
int flage = 0;
for (int j = 0; j < peoples - 1; ++j)
{
if (ptr[j].math < ptr[j + 1].math)
{
++flage;
temp = ptr[j];
ptr[j] = ptr[j + 1];
ptr[j + 1] = temp;
}
}
if (flage == 0)
break;
}
int j = 0;
for (; j < peoples; ++j)
{
if (ptr[j].number == number)
break;
}
return j + 1;
}
/*****英语排名*****/
int englishrank(struct Student* ptr, int peoples, string number)
{
struct Student temp;
//冒泡排序
for (int i = 0; i < peoples - 1; ++i)
{
int flage = 0;
for (int j = 0; j < peoples - 1; ++j)
{
if (ptr[j].english < ptr[j + 1].english)
{
++flage;
temp = ptr[j];
ptr[j] = ptr[j + 1];
ptr[j + 1] = temp;
}
}
if (flage == 0)
break;
}
int j = 0;
for (; j < peoples; ++j)
{
if (ptr[j].number == number)
break;
}
return j + 1;
}
/*****计算机排名*****/
int computerrank(struct Student* ptr, int peoples, string number)
{
struct Student temp;
//冒泡排序
for (int i = 0; i < peoples - 1; ++i)
{
int flage = 0;
for (int j = 0; j < peoples - 1; ++j)
{
if (ptr[j].computers < ptr[j + 1].computers)
{
++flage;
temp = ptr[j];
ptr[j] = ptr[j + 1];
ptr[j + 1] = temp;
}
}
if (flage == 0)
break;
}
int j = 0;
for (; j < peoples; ++j)
{
if (ptr[j].number == number)
break;
}
return j + 1;
}
/*****总分排名*****/
int allrank(struct Student* ptr, int peoples, string number)
{
struct Student temp;
//冒泡排序
for (int i = 0; i < peoples - 1; ++i)
{
int flage = 0;
for (int j = 0; j < peoples - 1; ++j)
{
if (ptr[j].ave < ptr[j + 1].ave)
{
++flage;
temp = ptr[j];
ptr[j] = ptr[j + 1];
ptr[j + 1] = temp;
}
}
if (flage == 0)
break;
}
int j = 0;
for (; j < peoples; ++j)
{
if (ptr[j].number == number)
break;
}
return j + 1;
}
/*****判断用户是否重复*****/
bool The_user_to_repeat(string number)
{
int peoples = showpeoples();
struct Student* stu = new struct Student[peoples];
Get_Mage(stu);
//cout << stu[0].number << endl;
int flage = 0;
for (int i = 0; i < peoples; ++i)
{
if (stu[i].number == number)
{
++flage;
break;
}
}
delete[]stu;
stu = NULL;
if (flage)
return true;
else
return false;
}