1084. Broken Keyboard (20)-水题
#include <iostream>
#include <cstdio>
#include <string.h>
#include <algorithm> using namespace std;
const int maxn=;
char str1[maxn];
char str2[maxn];
int vis[]; int main()
{
scanf("%s %s",str1,str2);
memset(vis,,sizeof(vis));
int len1=strlen(str1),len2=strlen(str2);
for(int i=;i<len1;i++){
if('a'<=str1[i] && str1[i]<='z'){
vis[str1[i]-'a']=;
}
else if('A'<=str1[i] && str1[i]<='Z'){
vis[str1[i]-'A']=; //傻了,之前写成str1[i]-'A'+'a' ....
str1[i]=str1[i]-'A'+'a';//转化成小写,方便后续操作
}
else if(str1[i]=='_'){
vis[]=; //'_'
}
else{
vis[str1[i]-''+]=; //0~9
}
}
for(int i=;i<len2;i++){
if('a'<=str2[i] && str2[i]<='z'){
vis[str2[i]-'a']=;
}
else if('A'<=str2[i] && str2[i]<='Z'){
vis[str2[i]-'A']=;
}
else if(str2[i]=='_'){
//if里面一开始少写了个=。。。导致WA。。。
vis[]=; //'_'
}
else{
vis[str2[i]-''+]=;
}
}
//要按照在str1中的顺序输出,并且是以大写字母的形式
for(int i=;i<len1;i++){
if(str1[i]=='_'){
if(vis[]==){
printf("_");
vis[]=;//输过一次就不需要再输出了
}
}
else if('a'<=str1[i] && str1[i]<='z'){
if(vis[str1[i]-'a']==){
printf("%c",str1[i]-'a'+'A');
vis[str1[i]-'a']=;
}
}
else{
if(vis[str1[i]-''+]==){
printf("%c",str1[i]);
vis[str1[i]-''+]=;
}
}
}
return ;
}
1084. Broken Keyboard (20)-水题的更多相关文章
- 1084. Broken Keyboard (20)【字符串操作】——PAT (Advanced Level) Practise
题目信息 1084. Broken Keyboard (20) 时间限制200 ms 内存限制65536 kB 代码长度限制16000 B On a broken keyboard, some of ...
- 1084. Broken Keyboard (20)
On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters ...
- PAT Advanced 1084 Broken Keyboard (20) [Hash散列]
题目 On a broken keyboard, some of the keys are worn out. So when you type some sentences, the charact ...
- PAT (Advanced Level) 1084. Broken Keyboard (20)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
- 【PAT甲级】1084 Broken Keyboard (20 分)
题意: 输入两行字符串,输出第一行有而第二行没有的字符(对大小写不敏感且全部以大写输出). AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #inclu ...
- pat1084. Broken Keyboard (20)
1084. Broken Keyboard (20) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue On a ...
- PAT 1084 Broken Keyboard
1084 Broken Keyboard (20 分) On a broken keyboard, some of the keys are worn out. So when you type ...
- 1084 Broken Keyboard (20 分)
1084 Broken Keyboard (20 分) On a broken keyboard, some of the keys are worn out. So when you type so ...
- pat 1084 Broken Keyboard(20 分)
1084 Broken Keyboard(20 分) On a broken keyboard, some of the keys are worn out. So when you type som ...
随机推荐
- 记一次隐秘的XSS漏洞挖掘
前言 在为某客户网站做渗透测试时发现一个有趣的事情.当我访问该网站的某条链接时服务器返回的是404页面.看到这里我当时就下意识的忽略它,但是后来又想了想这也不是完全没有价值,毕竟中间件及其版本都出来了 ...
- 菜鸟对APP界面设计的一些心得小结
1. 前言 当我看着我以前做的一些app界面,我意识到我应该把我的界面设计能力水平再提升一个,因为实在是丑啊!贴一些以前的设计: 现在看来,是不能看的了.我主要是做需求设计,后面也有一些美工的工作,我 ...
- postgresql----几何类型和函数
postgresql支持的几何类型如下表: 名字 存储空间 描述 表现形式 point 16字节 平面上的点 (x,y) line 32字节 直线 {A,B,C} lseg 32字节 线段 ((x1, ...
- BZOJ2095:[POI2010]Bridges(最大流,欧拉图)
Description YYD为了减肥,他来到了瘦海,这是一个巨大的海,海中有n个小岛,小岛之间有m座桥连接,两个小岛之间不会有两座桥,并且从一个小岛可以到另外任意一个小岛.现在YYD想骑单车从小岛1 ...
- JavaScript无阻塞加载具体方式
将脚本放在底部.\还是放在head中,用以保证在js加载前,能加载出正常显示的页面.\<script>标签放在\前 成组脚本:由于每个\<script>标签下载时阻塞页面解析过 ...
- vagrant特性——基于docker开发环境(docker和vagrant的结合)-1-基本使用
Docker vagrant提供了使用Docker作为provider(其他的provider有virtualBox.VMware\hyper-V等)的开箱即用支持.这允许你的开发环境由Docker容 ...
- shiro实战系列(二)之入门实战续
下面讲解基于实战系列一,所以相关的java文件获取pom.xml及其log4j文件同样适用于本次讲解. 一.Using Shiro Using Shiro 现在我们的 SecurityManager ...
- jsp el的内置对象
一.el内置对象(11个): pageScope (掌握) requestScope (掌握) applicationScope (掌握) sessionScope (掌握) param (了解) p ...
- HDU 2159 FATE(有选择物品总个数限制的完全背包,经典!!)
FATE Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status ...
- 委托、事件、匿名方法、Lambda
一.委托(delegate) 定义:public delegate void/类型 DefinedDelegate(参数1,参数2...) 委托是类型安全的. 委托实例:DefinedDe ...