PAT 1035

PAT的题有些很无聊的... (多数)

 1 #include <vector>
 2 #include <string>
 3 #include <iostream>
 4 #include <fstream>
 5
 6 using namespace std;
 7
 8 #define OJ
 9
10 #ifdef OJ
11 #define fin cin
12 #endif
13
14 struct Student{
15     string name;
16     bool is_male;
17     string id;
18     int grade;
19 };
20
21 int main(){
22 #ifndef OJ
23     ifstream fin("in.data");
24 #endif
25
26     int N;
27     fin >> N;
28
29     vector<Student> students;
30     for (int i = 0; i < N; i++){
31         Student stu;
32         fin >> stu.name;
33
34         char gender;
35         fin >> gender;
36
37         stu.is_male = (gender == ‘M‘ ? true : false);
38
39         fin >> stu.id;
40         fin >> stu.grade;
41
42         students.push_back(stu);
43     }
44
45     int male_grade = 101;
46     int femail_grade = -1;
47     int male_idx, femail_idx;
48     for (int i = 0; i < N; i++){
49         Student &stu = students[i];
50         if (stu.is_male){
51             if (stu.grade < male_grade){
52                 male_grade = stu.grade;
53                 male_idx = i;
54             }
55         }
56         else if (stu.grade > femail_grade){
57             femail_grade = stu.grade;
58             femail_idx = i;
59         }
60     }
61
62     bool na = false;
63     if (femail_grade == -1){
64         cout << "Absent" << endl;
65         na = true;
66     }
67     else {
68         cout << students[femail_idx].name << " " << students[femail_idx].id << endl;
69     }
70     if (male_grade == 101){
71         cout << "Absent" << endl;
72         na = true;
73     }
74     else {
75         cout << students[male_idx].name << " " << students[male_idx].id << endl;
76     }
77
78
79     if (na){
80         cout << "NA" << endl;
81     }
82     else {
83         cout << femail_grade - male_grade << endl;
84     }
85
86     return 0;
87 }
时间: 2024-10-25 07:45:21

PAT 1035的相关文章

PAT 1035. Password (20)

1035. Password (20) To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) fro

pat 1035 Password(20 分)

1035 Password(20 分) To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) fro

PAT 1035. 插入与归并(25)

根据维基百科的定义: 插入排序是迭代算法,逐一获得输入数据,逐步产生有序的输出序列.每步迭代中,算法从输入序列中取出一元素,将之插入有序序列中正确的位置.如此迭代直到全部元素有序. 归并排序进行如下迭代操作:首先将原始序列看成N个只包含1个元素的有序子序列,然后每次迭代归并两个相邻的有序子序列,直到最后只剩下1个有序的序列. 现给定原始序列和由某排序算法产生的中间序列,请你判断该算法究竟是哪种排序算法? 输入格式: 输入在第一行给出正整数N (<=100):随后一行给出原始序列的N个整数:最后一

PAT 甲级 1035 Password

https://pintia.cn/problem-sets/994805342720868352/problems/994805454989803520 To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to di

PAT甲级——1035 Password (20分)

To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) from O (o in uppercase)

PAT Advanced 1035 Password (20分)

To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) from O (o in uppercase)

PAT甲题题解-1035. Password (20)-水

题意:给n个用户名和密码,把密码中的1改为@,0改为%,l改为L,O改为o. 让你输出需要修改密码的用户名个数,以及对应的用户名和密码,按输入的顺序.如果没有用户需要修改,则输出对应的语句,注意单复数... 没啥好说的,就for一遍密码,把需要改的改下,存入到ans中去. #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> #include <cm

PAT:1035. Password (20) AC

#include<stdio.h> #include<string.h> typedef struct STU { char mID[15]; char mpass[15]; bool tag; }STU; STU arr[1010]; int main() { memset(arr,0,sizeof(arr)); int n,change=0; scanf("%d",&n); for(int i=0 ; i<n ; ++i) { scanf(&q

PAT从零单排

偶然原因开始了PAT之旅前前后后用了3天时间刷完了PAT Basic(35题) 现在记录下从零单排的过程,总的来说题目很简单 当然有个别题目的坑点还是比较给力的,准确的说,题目的数据很给力 1001. 害死人不偿命的(3n+1)猜想 (15) 纯模拟题,是偶数除以2,奇数(3n+1)除以2,到1结束 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int n,