HUA-1-182-结构体数组

Description

输入学生人数n,然后构建一个结构体数组,结构体包含学号和学生成绩(都是int类型),然后输出成绩不及格(<60)的学生的学号。

Input

输入n,接着输入n名学生的信息,主要是学号和成绩;

Output

输出成绩不及格学生的学号,每个学号一行。

Sample Input 1

1
2
3
4
5
4
121212 5
121213 100
121216 70
121218 60

Sample Output 1

1
121212

Code

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
#include <iostream>
#include <vector>
using namespace std;

struct stu{
int id;
int grade;
stu(int id,int grade){
this->id = id;
this->grade = grade;
}
};


int main(){
int n;
scanf("%d",&n);
int id,grade;
vector<stu> v;
while(n>0){
scanf("%d %d",&id,&grade);
stu s(id,grade);
v.push_back(s);
n--;
}

for(int i=0;i<v.size();i++){
if(v[i].grade<60)
printf("%d\n",v[i].id);
}


return 0;
}

----\(˙<>˙)/----赞赏一下吧~