【PTA-A】1036 Boys vs Girls(普通结构体)

被搜狗输入法背刺了!偷偷装的 “AI 汪仔” 狂占 CPU!手把手教你如何彻底关闭删除搜狗AI功能AI汪仔 手把手教你如何彻底关闭删除搜狗输入法的AI汪仔🚀 阅读详情

题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805453203030016

题目要求第一行输出成绩最高的女生;第二行成绩最差的男生;第三行女生最高-男生最低的值

简单的用结构体就可以实现,这里要注意一下名字和编号的长度一定要>10!(这里我开头刚好设置了10导致一直A不了)

我的做法是输入的时候记录男女次数,先从大到小排一次,输出女生并保存最高分。再从小到大排一次,输出男生并保存最低分。用flag标志是否有男/女,如果没有就直接输出NA了

#include<iostream>
#include<algorithm>
using namespace std;
struct Node {
	char na[15], sex, nu[15];
	int g;
}N[10001];

bool cmp1(Node a, Node b) {
	if (a.g < b.g)return true;
	else return false;
}
bool cmp2(Node a, Node b) {
	if (a.g > b.g)return true;
	else return false;
}

int main() {
	int t,f=0,m=0,flag=0;
	int gmax=0, gmin=0;
	cin >> t;
	for (int i = 0; i < t; i++) {
		cin >> N[i].na >> N[i].sex >> N[i].nu >> N[i].g;
		if (N[i].sex=='F')f++;
		else m++;
	}
	sort(N, N + t, cmp2);
	if (f == 0) {cout << "Absent"<<endl; flag = 1;}
	else {
		for (int i = 0; i < t; i++) {
			if (N[i].sex == 'F') {
				gmax = N[i].g;
				cout << N[i].na <<" "<< N[i].nu<<endl;
				break;
			}
		}
	}
	sort(N, N + t, cmp1);
	if (m == 0) { cout << "Absent"<<endl; flag = 1; }
	else {
		for (int i = 0; i < t; i++) {
			if (N[i].sex == 'M') {
				gmin = N[i].g;
				cout << N[i].na <<" "<< N[i].nu<<endl;
				break;
			}
		}
	}
	if (flag == 1)cout << "NA";
	else {
		cout << abs(gmax - gmin);
	}
	return 0;
}

 

用一组可复现实验讲清 ABAP 内表 Standard / Sorted / Hashed 的性能差异 摘要(150字): SAP项目中性能问题常源于ABAP内表选型不当。标准表(STANDARD TABLE)写入快但查找慢(线性扫描),适合遍历场景;排序表(SORTED TABLE)保持有序,支持二分查找,适合范围查询;哈希表(HASHED TABLE)基于唯一键实现常数级查找,适合高频精确匹配。实验表明:标准表+BINARY SEARCH需预排序,成本可能高于直接使用排序表;哈希表在键匹配时性能最优。Gateway和RAP场景中,内表选型直接影响接口响应,建议根据读写负载(追加/遍历/精确查找)选择对应类 阅读详情

相关推荐

【技术解析】华为智算中心:昇腾AI算力与无损网络如何驱动大模型训练

本文深入解析了华为智算中心如何通过昇腾AI算力与超融合以太无损网络的协同,驱动千亿参数大模型的高效训练。昇腾NPU提供专用计算引擎,而基于RoCE的无损网络则通过PFC、ECN等技术确保万卡集群间的高带宽、零丢包通信,实现算力利用率最大化,解决大规模AI训练的核心瓶颈。

weixin_29311017的博客 191

PTA 甲级1036 Boys vs Girls (25分)

1036 Boys vs Girls (25分) 文章目录1036 Boys vs Girls (25分)题目原文Input Specification:Output Specification:Sample Input 1:Sample Output 1:Sample Input 2:Sample Output 2:生词题目大意 题目原文 This time you are asked to ...

Huangpengyu123的博客 361

基于Simulink的防空导弹六自由度弹道建模与仿真实战

本文详细介绍了基于Simulink的防空导弹六自由度弹道建模与仿真方法。通过分析导弹动力学原理、Simulink环境配置、气动力建模、推进与控制系统设计等关键环节,提供了一套完整的实战指南。文章特别强调了六自由度模型在防空导弹仿真中的重要性,并分享了常见问题排查与优化建议,为相关领域工程师提供实用参考。

apple5的专栏 865

PTA(A)1036 Boys vs Girls (25 分)

Sample Input 1: 3 Joe M Math990112 89 Mike M CS991301 100 Mary F EE990830 95 Sample Output 1: Mary EE990830 Joe Math990112 6 Sample Input 2: 1 Jean M AA980920 60 Sample Output 2: Absent Jean AA980...

Sqssq的博客 189

WOL唤醒配置(以太网、PHY、MAC)

MAC 就是以太网控制器,属于OSI的数字链路层。phy 属于OSI的物理层(Physical layer),所以叫phy。CPU Mac与phy通信通过MII接口,数据的传输通过MDIO数据线。通过配置phy的相关寄存器实现不同的功能。

qq_58264156的博客 8629

Github多人协作

最近有门课程需要几个人一起开发一个项目,此前我们基本都是单干的,多人合作意味着需要及时将我们每个人的代码进行合并,U盘传文件这种方式太慢了,效率不行,而且没法解决两个人同时修改一个文件的问题,这次我们就尝试使用Github来协助开发。下面就来记录一下这次开发遇到的一些问题和解决的方法。 Git的安装 从官网下载最新版按照默认安装即可。 此处不多加说明。 Git常用命令 在此放上一...

yzr1216的博客 1万+

A1036 Boys and Girls(女最高减男最低)

源代码: #include &lt;stdio.h&gt; struct person{ char name[15]; char ID[15]; int score; }M,F,temp; void init(){ M.score=101; F.score=-1; } int main(){ init(); int n; char gender; scanf("%d",&am...

mlhypyl的博客 352

【Unity Animation 2D】从零到一:骨骼绑定与IK动画实战指南

本文详细介绍了Unity中2D骨骼绑定与IK动画的实战流程,从角色素材准备、骨骼系统创建到权重绘制和IK设置,逐步指导开发者掌握2D动画制作技巧。通过反向动力学(IK)技术,实现更自然的角色动画效果,适用于游戏开发和动画制作。

weixin_30430677的博客 369

PTA A1036 Boys vs Girls

题目看懂了(*^▽^*) #include&lt;cstdio&gt; using namespace std; struct student{ char name[11]; char sex[2]; char id[11]; int grade; }girl,boy,temp; int main(){ girl.grade=0; boy.grade=100; in...

一只小仙女的博客 484

13 万字 C 语言从入门到精通保姆级教程2021 年版

13 万字C语言保姆级教程,从入门到精通。

李南江 61万+

【部署】Docker部署OpenClaw及常见问题解决(win11)

给AI单独开一个隔离的小容器,AI执行所有命令、下载文件都在这个小盒子里,就算AI被诱导执行危险命令,也不会影响你Win11本机的文件和系统,是必开的安全功能。Docker容器里的OAuth回调,会尝试在你Win11本机的1455端口捕获认证信息,但容器和Win11本机的网络隔离,导致浏览器访问不到这个回调地址。「挂载」就是把你Win11本机的文件夹,共享给容器里的「虚拟小电脑」,两边都能读写文件,比如你想让AI操作你D盘里的代码文件,就需要挂载。

海兰 4695

PTA A1036 Boys vs Girls (25分)

PTA A1036 Boys vs Girls (25分) 简单排序题,也没什么好写的 #include<bits/stdc++.h> using namespace std; struct student{ string name; string gender; string id; int grade; }; bool cmp(student a...

weixin_39339878的博客 108

雷电模拟器+ADB全栈爬虫实战:绕过APP反爬的终极方案与2026最新踩坑指南

现在主流的模拟器爬虫方案有三种,我对比了它们的优缺点,最终选择了雷电模拟器+纯ADB控制方案优势劣势适用场景Appium生态完善,支持多平台重依赖,启动慢,反爬检测率高大型项目,需要跨平台Airtest图像识别强大,上手简单性能差,多开不稳定,反爬检测率高简单的自动化测试纯ADB轻量无依赖,速度快,反爬检测率极低需要自己封装工具工业级爬虫,追求稳定性和反爬逆向接口速度最快,性能最好开发成本高,维护成本高接口简单,反爬弱的APP为什么选雷电模拟器?

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 1982

PAT A1036 Boys vs Girls (25)

PTA跳转:原题链接 这道题目首先输入1个整型n,接着输入n行数据,每行数据包括“姓名,性别,学号,成绩”四项信息。找出女生里面成绩最高的和男生里面成绩最低的,前两行分别输出这位女生和男生的姓名和学号,第三行输出这两位学生的成绩之差。 如果输入数据里面没有男生或者没有女生,再进行特殊处理。 代码: #include <iostream> using namespace std; st...

koori_145的博客 270

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

[ PAT-A ] 1036 Boys vs Girls (C++)

题目描述 This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students. Input Specification: Each input file contains...

Emerson的铺子 418

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

PTA甲级考试真题练习36——1036 Boys vs Girls

题目 思路 水题,将男生女生分开存储,分别排序,输出 代码 #include <iostream> #include <string> #include<algorithm> #include<vector> #include<stack> #include<map> #include<set> #includ...

醉等佳人归 194

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

【ACM】- PAT.A1036 Boys vs Girls 【水题】

题目链接 题目分析 (略) 解题思路 (略) AC程序(C++) /********************************** *@ID: 3stone *@ACM: PAT.A1036 Boys vs Girls *@Time: 18/9/20 *@IDE: VScode 2018 + clang++ ***********************************/ #i...

三个石头 230

PTA 1036 Boys vs Girls

题目描述 分析: 此题比较简单,只需要找出女生成绩最大和男生成绩最小的即可,可以用结构体存储学生的信息。 #include<iostream> using namespace std; struct student{ string name; string id; int score; }male,fale; int main(){ male.score=101; fale.score=-1; int n; cin>>n; char gender; string

qaqaqa666的博客 116

PTA甲级 1036 Boys vs Girls (C++)

This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students. Input Specification: Each input file contains one test case. Each case contains a positive integer NNN, follo

Misdirection 182

PTA甲级 1036 Boys vs Girls (25point(s))

This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students. Input Specification: Each input file contains one tes...

Seqlist_base的博客 466

PTA甲级——1036 Boys vs Girls (25分)

This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students. Input Specification: Each input file contains one test case. Each case contains a positive integer N, followe

weixin_45816550的博客 172

pta--1036 Boys vs Girls(25 分)(结构体)

题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805453203030016 【分析】定义结构体,然后排序输出再做判断就好; #include&lt;cstdio&gt; #include&lt;iostream&gt; #include&lt;algorithm&gt; #include&lt;vect...

来啦(#^.^#) 339

已知层次序列及结点的度,求树的孩子-兄弟链表

一、算法思想 我们已知层次序列数组A[],以及各结点对应的度。可以创建一个临时链表组,先在组内存放一个个单个的结点,再将各结点通过父子关系链接。 例如,我们有 结点 A B C D E 度 2 2 0 0 0 这样的序列和度的情况【左图】。要转换为如下的孩子-兄弟链表【右图】。 先构造临时树temp【包括数据,左孩子...

Netceor的博客 3050

【PTA-B】1012 数字分类(数字除法)

给定一系列正整数,请按要求对数字进行分类,并输出以下 5 个数字: A​1​​= 能被 5 整除的数字中所有偶数的和; A​2​​= 将被 5 除后余 1 的数字按给出顺序进行交错求和,即计算n​1​​−n​2​​+n​3​​−n​4​​⋯; A​3​​= 被 5 除后余 2 的数字的个数; A​4​​= 被 5 除后余 3 的数字的平均数,精确到小数点后 1 位; A​5​​...

Netceor的博客 2396

Dev_C++ 安装和使用

一、安装 到如下链接安装 https://sourceforge.net/projects/orwelldevcpp/ 二、使用 1、创建新项目 File → New → Project 2、运行 按F10运行

Netceor的博客 2355

Visual Studio导入libtorch(Cuda版)

Visual Studio导入libtorch(Cuda版)

Netceor的博客 1865
上一篇: 【PTA-A】1054 The Dominant Color
下一篇: 【PTA-B】1010 一元多项式求导 (25 分)
Netceor
博客等级 码龄9年 1046粉丝 306原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值