CCF-CSP 201412-1 门禁系统 C++ 满分题解

题目:

CCF-CSP 201412-1 门禁系统 C++ 满分题解_第1张图片

代码: 

struct Per {
	int name;
	int time;
};

int main() {
	vector  per;
	int n;
	cin >> n;
	int x;
	while (n--) {
		cin >> x;
		bool f = 0;
		for (auto &s : per) {
			if (s.name == x) {
				f = 1;
				s.time++;
				cout << s.time << " ";
			}
		}
		if (f == 0) {
			Per newper;
			newper.name = x ;
			newper.time = 1;
			cout << 1 << " ";
			per.push_back(newper);
		}
	}
}

你可能感兴趣的:(c++,开发语言)