-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInput.cpp
More file actions
218 lines (190 loc) · 7.36 KB
/
Copy pathInput.cpp
File metadata and controls
218 lines (190 loc) · 7.36 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
//
// Created by Wen34 on 2026/3/26.
//
#include "Input.h"
#include <iostream>
#include "struct.h"
#include <vector>
#include "Process.h"
#include <cstring>
using namespace std;
void Show_Menu() // 菜单
{
cout << "欢迎来到“Rolex”职位申请系统!" << endl;
cout << "1. 输入应聘者信息" << endl;
cout << "2. 显示所有应聘者信息" << endl;
cout << "3. 显示所有应聘者录取通知书" << endl;
cout << "4. 查询应聘者信息" << endl;
cout << "5. 删除所有应聘者成绩总表" << endl;
cout << "0. 退出系统" << endl;
}
// int Application_Count()
// {
// cout << "请输入应聘者人数 (不超过50): "; // 提示输入应聘者数量
//
// int n;
//
// cin >> n;
//
// while (n >= 50 || n < 0)
// {
// cout << "输入错误,请重新输入!" << endl; // 提示输入错误
// cin >> n;
// }
//
// return n;
// }
void Get_Appli_Inform(vector<Tmarks> &applicants) // 输入应聘者信息
{
// 1. 清空旧数据(防止用户多次调用“输入信息”时数据重复叠加)
//applicants.clear();
int m = applicants.size(); // 获取当前已存在的数据个数
int n;
cout << "请输入应聘者人数 (最多不超过" << Max_Application - m <<"): ";
cin >> n;
// while (m + n > Max_Application || n < 0)
// {
// if (n > Max_Application)
// {
// cout << "输入超过最大容量(50),请重新输入!";
// cin >> n;
// }
// else if (n < 0)
// {
// cout << "输入小于0,请重新输入!";
// cin >> n;
// }
// else
// {
// cout << "已有" << m << "位应聘者信息已存在,请输入小于" << Max_Application - m << "位应聘者信息," << endl;
// cout << "请输入应聘者人数" << endl;
// }
// 输入校验
while (m + n > Max_Application || n < 0) // 输入校验
{
if (n > Max_Application) // 输入超过最大容量
{
cout << "输入超过最大容量(50),请重新输入!";
cin >> n;
}
else if (n < 0) // 输入小于0
{
cout << "输入小于0,请重新输入!";
cin >> n;
}
else
{
cout << "已有" << m << "位应聘者信息已存在,请输入小于" << Max_Application - m << "位应聘者信息," << endl;
cout << "请输入应聘者人数:";
cin >> n;
}
}
cout << "\n请依次输入每位应聘者的信息:" << endl;
cout << "(姓名 性别 年龄 学历 任科级干部年限 现工作单位 政策法律基础 语文 英语 计算机基础 口试)" << endl;
// 2. 循环 n 次
for (int i = 0; i < n; i++)
{
//在循环内部定义一个临时结构体
// 每次循环都会创建一个新的 temp
Tmarks temp;
cout << "应聘者 " << i+1 << ": " << endl;
cout << "姓名: (不超过20个字符)";
cin >> temp.name;
while (strlen(temp.name) > 20) // 姓名长度限制
{
cout << "输入错误,请重新输入!" << endl;
cout << "姓名: (不超过20个字符)";
cin >> temp.name;
}
cout << "性别:(男:M 女:W) "; // 性别输入提示
cin >> temp.info.sex;
while (temp.info.sex != "M" && temp.info.sex != "W") // 性别输入校验
{
cout << "输入错误,请重新输入!" << endl;
cout << "性别:(男:M 女:W) ";
cin >> temp.info.sex;
}
cout << "年龄: "; // 年龄输入提示
cin >> temp.info.age;
while (temp.info.age < 18 || temp.info.age > 60) // 年龄输入校验
{
cout << "输入错误,请重新输入!" << endl;
cout << "年龄: ";
cin >> temp.info.age;
}
cout << "学历:(博士:B 硕士:M 本科:U 其他:O) "; // 学历输入提示
cin >> temp.info.schoolrecord;
while (temp.info.schoolrecord != "B" && temp.info.schoolrecord != "M" && temp.info.schoolrecord != "U" && temp.info.schoolrecord != "O") // 学历输入校验
{
cout << "输入错误,请重新输入!" << endl;
cout << "学历:(博士:B 硕士:M 本科:U 其他:O) ";
cin >> temp.info.schoolrecord;
}
cout << "任科级干部年限: "; // 任科级干部年限输入提示
cin >> temp.info.worklen;
while (temp.info.worklen < 0 || temp.info.worklen > 20) // 任科级干部年限输入校验
{
cout << "输入错误,请重新输入!" << endl;
cout << "任科级干部年限: ";
cin >> temp.info.worklen;
}
cout << "现工作单位: "; // 现工作单位输入提示
cin >> temp.info.wordsite;
while (strlen(temp.info.wordsite) > 100) // 现工作单位长度限制
{
cout << "输入错误,请重新输入!" << endl;
cout << "现工作单位: (不超过100个字符)";
cin >> temp.info.wordsite;
}
cout << "政策法律基础: "; // 政策法律基础输入提示
cin >> temp.mark.pol;
while (temp.mark.pol < 0 || temp.mark.pol > 100) // 政策法律基础输入校验
{
cout << "输入错误,请重新输入!" << endl;
cout << "政策法律基础: ";
cin >> temp.mark.pol;
}
cout << "语文: "; // 语文输入提示
cin >> temp.mark.chn;
while (temp.mark.chn < 0 || temp.mark.chn > 100) // 语文输入校验
{
cout << "输入错误,请重新输入!" << endl;
cout << "语文: ";
cin >> temp.mark.chn;
}
cout << "英语: "; // 英语输入提示
cin >> temp.mark.eng;
while (temp.mark.eng < 0 || temp.mark.eng > 100) // 英语输入校验
{
cout << "输入错误,请重新输入!" << endl;
cout << "英语: ";
cin >> temp.mark.eng;
}
cout << "计算机基础: "; // 计算机基础输入提示
cin >> temp.mark.com;
while (temp.mark.com < 0 || temp.mark.com > 100) // 计算机基础输入校验
{
cout << "输入错误,请重新输入!" << endl;
cout << "计算机基础: ";
cin >> temp.mark.com;
}
cout << "口试: "; // 口试输入提示
cin >> temp.mark.oral;
while (temp.mark.oral < 0 || temp.mark.oral > 100) // 口试输入校验
{
cout << "输入错误,请重新输入!" << endl;
cout << "口试: ";
cin >> temp.mark.oral;
}
// 3.计算各项分数
// 依赖于上面输入的数据
temp.Srecord = calcSchoolScore(temp.info.schoolrecord[0]);
temp.Sage = calcAgeScore(temp.info.age);
temp.Swlen = calcWorkScore(temp.info.worklen);
temp.total = calcTotalScore(temp);
// 4.核心操作:将填好数据的结构体“推入”vector末尾
// 这就是“写完一个加入一个”的实现
applicants.push_back(temp);
}
// 循环结束,vector 自动增长到了 n 的大小
}