-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainProcesA.cpp
More file actions
264 lines (177 loc) · 4.22 KB
/
MainProcesA.cpp
File metadata and controls
264 lines (177 loc) · 4.22 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
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
256
257
258
259
260
261
262
263
264
#pragma warning( disable : 4996)
//#include "define_the_head.h"
#include "newstudents.h"
#include "savefile.h"
#include<iostream>
#include <string>
#include<ctime>
using namespace std;
extern void getfile(linken& studen, fstream& file);
extern bool GetStoredMessage(linken& head, int size);
extern bool Savefile(linken* head);
extern void inital(linken& ptr, string NAME, string XUEHAO, tm BORNTIMR, bool SEX, int CP, int MATH, int ENGLISH);
extern AllScore clculate(linken);
extern void Sort(linken*, linken*);
extern void clear(linken&);
enum input {
INPUT ,
DELETE ,
CHANGE,
EXPRESSALL,
CLACULATE,
SEARCH,
SORT,
EXIT,
CLEAR
};
linken head,prehead;
int main()
{
//TODO 1.初始化屏幕 1.5 从历史文件读取数据 2.建立while循环 3.读取数据 4检查有没有错误5.进行运算 6.清空文件后将文件写入电脑
prehead.next = &head;
//linken *const suo = &head;
int num = 0;
if (GetStoredMessage(head, 0))
return 1;
auto temp = head;
while (temp.next != NULL)
{
//cout << temp.mamber.name << endl;
printf("%s\n", temp.mamber.name);
cout << temp.mamber.xuehao << endl;
temp = *(temp.next);
}
if (temp.next == NULL)
cout << temp.mamber.name << "this is end of file\n";
//text
if (1)
{
if (!head.next)
{
cout << "\n it`s empty";
}
linken temp = head;
while (0)//temp.next != NULL)
{
//cout << temp.mamber.name << endl;
printf("%s", temp.mamber.name);
temp = *(temp.next);
}
if (temp.next == NULL)
cout << "in the end/n";
}
//3.建立while循环
while (1)
{
//初始化屏幕信息,显示
cout << "请输入想要执行的操作并执行/n";
cout << "输入0添加学生,输入1删除学生()关键词为学号,输入2改变学生信息,输入3\n"
<< "展示所有学生信息,输入5搜索学生信息,输入6按照关键字排序,输入7退出谢谢" << endl;
cin >> num;
switch (num)
{
case INPUT:
{
string nameing;
//nameing.resize(17);
cin >> nameing;
string xuehao;
//xuehao.resize(11);
cin >> xuehao;
//scanf("%s", &xuehao[0]);
int tempint0 = 0;
cout << "input the int";
cin >> tempint0;
int tempint1 = 0;
cout << "input the int";
cin >> tempint1;
int tempint2 = 0;
cout << "input the int";
cin >> tempint2;
tm time{ 0 };
inital(head, nameing, xuehao, time, 1, tempint0, tempint1, tempint2);
}
break;
case DELETE:
break;
case CHANGE:
{
}
break;
case EXPRESSALL:
{
//ddwwsdadadaddwwsslinken tempofhead = *suo;
cout << "head is " << &head << endl;
if(!head.next)
{
cout << "it`s empty";
}
linken temp = head;
/*do
{
cout << temp.mamber.name << endl;
temp = *(temp.next);
} while (temp.next );
*/
while (temp.next != NULL)
{
//cout << temp.mamber.name << endl;
printf("%s\n", temp.mamber.name);
printf("%s\n", temp.mamber.xuehao);//为啥学号后面有东西,,
temp= *(temp.next);
}
if (temp.next == NULL)
cout << temp.mamber.name<<"this is end of file";
//text
/*
while (tempofhead.last != nullptr)
{
cout << tempofhead.next<< endl;
cout << tempofhead.mamber.name << endl;
tempofhead = *(tempofhead.last);
cout << tempofhead.next << endl;
}
if (tempofhead.last == nullptr)
cout << "in the beg/n";
*/
}
break;
case CLACULATE:
{//function of calculate the average
AllScore score = clculate(head);
cout << "----------------average-----score-------\n"
<< "c=" << score.Cp << " m=" << score.math << " e=" << score.English << endl;
}
break;
case SEARCH:
{
cout << "witch one you want?name1 xuehao2 sex3? ";
}
break;
case SORT:
{
cout << &head << endl;
if (head.next == NULL)
{
cout << " just one students";
break;
}
Sort((head.next) , NULL);
auto temp = head, * ptemp = &temp;
while (ptemp != NULL)
{
cout << ptemp->mamber.CProgram << " " << endl;
ptemp=ptemp->next;
}
}
break;
case EXIT:
Savefile(&head);
return 0;
case CLEAR :
{
clear(head);
}
}
}
}