博客
关于我
PAT乙级 1032 挖掘机技术哪家强 (20分) & 1033 旧键盘打字 (20分)
阅读量:610 次
发布时间:2019-03-12

本文共 1445 字,大约阅读时间需要 4 分钟。

1032 挖掘机技术哪家强 (20分)

只需要注意数组个数要取大,不然最后一个测试点出错。

#include
#include
#include
using namespace std;int main() { int sum = 0; cin >> sum; int bian = 0, fen = 0,max=0,maxbian=0,maxfen=0; int arr[1000000] = { 0 };//这里一定要取大,不然最后一个测试点不通过 for (int i = 0; i < sum; i++) { cin >> bian >> fen; arr[bian] += fen; if (bian > max)//找出最大编号,减少计算次数 max = bian; } for (int i = 1; i <= max; i++)//找出最大点 { if (maxfen < arr[i]) { maxbian = i; maxfen = arr[i]; } } cout << maxbian << " " << maxfen; return 0;}

1033 旧键盘打字 (20分)

需要用getline输入,因为题目要求是坏键盘可以为空,cin无法输入空,最后一个测试点就是过不去????

#include
#include
#include
using namespace std;int main(){ string a, b; getline(cin, a); getline(cin, b); int temp = 0; if (!a.size()) { for (int i = 0; i < b.size(); i++) cout << b[i]; return 0; } for (int i = 0; i < a.size(); i++) { if (a[i] == '+') { for (int i = 0; i < b.size(); i++) { if (b[i] >= 'A' && b[i] <= 'Z') b[i] = '*'; if (b[i] == '+') b[i] = '*'; } } else if (a[i] >= 'A' && a[i] <= 'Z') { char temp = a[i] - 'A' + 'a'; for (int i1 = 0; i1 < b.size(); i1++) { if(b[i1]==temp) b[i1] = '*'; } } else { for (int i1 = 0; i1 < b.size(); i1++) { if(b[i1]==a[i]) b[i1] = '*'; } } } for (int i = 0; i < b.length(); i++) { if (b[i] != '*') { cout << b[i]; temp = 1; } } if (temp == 0)//如果全都是无法输出就输出一个回车 { cout << endl; } return 0;}

 

转载地址:http://sfrxz.baihongyu.com/

你可能感兴趣的文章
Nmap渗透测试指南之指纹识别与探测、伺机而动
查看>>
Nmap端口扫描工具Windows安装和命令大全(非常详细)零基础入门到精通,收藏这篇就够了
查看>>
NMAP网络扫描工具的安装与使用
查看>>
NMF(非负矩阵分解)
查看>>
nmon_x86_64_centos7工具如何使用
查看>>
NN&DL4.1 Deep L-layer neural network简介
查看>>
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.7 Parameters vs Hyperparameters
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>