1 #include <iostream>
2 #include <string>
3
4 using namespace std;
5
6 struct Infor
7 {
8 public:
9 int num;
10 string name;
11 int score;
12 };
13
14 Infor find(Infor *a, int n, int num)
15 {
16 Infor result;
17 for (int i = 0; i < n; i++)
18 {
19 if (a[i].num == num)
20 {
21 result.name = a[i].name;
22 result.score = a[i].score;
23 }
24 }
25 return result;
26 }
27
28 int main()
29 {
30
31 Infor stu[4] = {
32 { 1024, "小甲鱼", 100 },
33 { 1026, "不知火舞", 60 },
34 { 1028, "黑夜", 40 },
35 { 1030, "迷途", 20 }
36 };
37
38 Infor result = find(stu, 4,1028);
39 cout << result.name << " " << result.score << endl;
40
41 int u;
42 cin >> u;
43 return 0;
44 }