题解 | #查找学生信息#

查找学生信息

https://www.nowcoder.com/practice/fe8bff0750c8448081759f3ee0d86bb4

#include <iostream>
#include <iostream>

using namespace std;

struct Student{
	string num;
	string name;
	string sex;
	int age;
};

Student stu[1010];

int main () {
	int n;
	while (cin >> n){
		for (int i = 0; i < n; i++){
			cin >> stu[i].num >> stu[i].name >> stu[i].sex >> stu[i].age;
		}
		int m, j;
		string findnum;
		cin >> m;
		for (int i = 0; i < m; i++){
			cin >> findnum; 
			for (j = 0; j < n; j++){
				if (findnum == stu[j].num){
					cout << stu[j].num << " " << stu[j].name << " " << stu[j].sex << " " << stu[j].age << endl;
					break;
				}
			}
			if (j == n){
				cout << "No Answer!" << endl;
			}
		}
	}
	return 0;
}

全部评论

相关推荐

10-11 14:44
济南大学 Java
点赞 评论 收藏
分享
notbeentak...:真的nc,算毕业6月份,要给这种b公司打半年多白工😅
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务