Codeforces Round #424 B. Keyboard Layouts(字符串,匹配,map)
#include <stdio.h>
#include <string.h> char ch[][];
char t[]; int num[]; int main(){
scanf("%s",ch[]);
scanf("%s",ch[]);
scanf("%s",t); for(int i=;i<strlen(ch[]);i++){
num[ch[][i]-'a']=i;
} for(int i=;i<strlen(t);i++){
if(<=t[i]-''&&t[i]-''<=){
printf("%c",t[i]);
}else if('a'<=t[i]&&t[i]<='z'){
printf("%c",ch[][num[t[i]-'a']]);
}else if('A'<=t[i]&&t[i]<='Z'){
printf("%c",ch[][num[t[i]-'A']]-);
} }
printf("\n");
return ;
}
#include <stdio.h>
#include <string.h>
char key[];
int main ()
{
char b,f[],l[],sent[];
int i,j,x;
scanf("%s",f);
scanf("%s",l);
scanf("%s",sent);
for(i=;i<;i++)
{
key[f[i]]=l[i];
key[f[i]-]=l[i]-;
}
for(i=;i<strlen(sent);i++)
{
if(key[sent[i]])
printf("%c",key[sent[i]]);
else
{ printf("%c",sent[i]);
}
}
return ; }
#include<stdio.h> int main()
{
char a[],b[],ch;
int i=;
while((a[i]=getchar())!='\n') i++;
i=;
while((b[i]=getchar())!='\n') i++;
while((ch=getchar())!='\n')
{
if(ch<) printf("%c",ch);
else if(ch<)
{
ch+=;
for(i=;i<;i++)
if(a[i]==ch)
{
printf("%c",b[i]-);
break;
}
}
else
for(i=;i<;i++)
if(a[i]==ch)
{
printf("%c",b[i]);
break;
}
}
return ;
}
#include <bits/stdc++.h>
using namespace std; int main()
{
char a[],c;
int i;
string s1,s2,s;
cin>>s1>>s2>>s;
for(i=;i<;++i)
a[s1[i]]=s2[i];
for(i=;i<s.length();++i)
{
if(s[i]>=&&s[i]<=)
{
c=s[i]+;
s[i]=a[c]-;
}
else if(s[i]>=&&s[i]<=)
{
s[i]=a[s[i]];
}
}
cout<<s;
return ;
}
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std; char s1[],s2[],ch[],s[];
int len; int main()
{
scanf("%s%s%s",s1,s2,s);
for(int i=;i<=;i++)
{
ch[s1[i]]=s2[i];
}
len=strlen(s);
for(int i=;i<len;i++)
{
if(s[i]>='A'&&s[i]<='Z')
{
s[i]+=;
s[i]=ch[s[i]]-;
}
else if(s[i]>='a'&&s[i]<='z')
s[i]=ch[s[i]];
else
s[i]=s[i];
}
printf("%s\n",s);
return ;
}
1 second
256 megabytes
standard input
standard output
There are two popular keyboard layouts in Berland, they differ only in letters positions. All the other keys are the same. In Berland they use alphabet with 26 letters which coincides with English alphabet.
You are given two strings consisting of 26 distinct letters each: all keys of the first and the second layouts in the same order.
You are also given some text consisting of small and capital English letters and digits. It is known that it was typed in the first layout, but the writer intended to type it in the second layout. Print the text if the same keys were pressed in the second layout.
Since all keys but letters are the same in both layouts, the capitalization of the letters should remain the same, as well as all other characters.
The first line contains a string of length 26 consisting of distinct lowercase English letters. This is the first layout.
The second line contains a string of length 26 consisting of distinct lowercase English letters. This is the second layout.
The third line contains a non-empty string s consisting of lowercase and uppercase English letters and digits. This is the text typed in the first layout. The length of s does not exceed 1000.
Print the text if the same keys were pressed in the second layout.
qwertyuiopasdfghjklzxcvbnm
veamhjsgqocnrbfxdtwkylupzi
TwccpQZAvb2017
HelloVKCup2017
mnbvcxzlkjhgfdsapoiuytrewq
asdfghjklqwertyuiopzxcvbnm
7abaCABAABAcaba7
7uduGUDUUDUgudu7
Codeforces Round #424 B. Keyboard Layouts(字符串,匹配,map)的更多相关文章
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)
http://codeforces.com/contest/831 A. Unimodal Array time limit per test 1 second memory limit per te ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem A - B
Array of integers is unimodal, if: it is strictly increasing in the beginning; after that it is cons ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) A 水 B stl C stl D 暴力 E 树状数组
A. Unimodal Array time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- 【Codeforces Round #424 (Div. 2) B】Keyboard Layouts
[Link]:http://codeforces.com/contest/831/problem/B [Description] 两个键盘的字母的位置不一样; 数字键的位置一样; 告诉你第一个键盘按某 ...
- Codeforces Round #410 (Div. 2)(A,字符串,水坑,B,暴力枚举,C,思维题,D,区间贪心)
A. Mike and palindrome time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...
- Codeforces Round #548 (Div. 2) E 二分图匹配(新坑) or 网络流 + 反向处理
https://codeforces.com/contest/1139/problem/E 题意 有n个学生,m个社团,每个学生有一个\(p_i\)值,然后每个学生属于\(c_i\)社团, 有d天,每 ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)A,B,C
A:链接:http://codeforces.com/contest/831/problem/A 解题思路: 从前往后分别统计递增,相等,递减序列的长度,如果最后长度和原序列长度相等那么就输出yes: ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem D (Codeforces 831D) - 贪心 - 二分答案 - 动态规划
There are n people and k keys on a straight line. Every person wants to get to the office which is l ...
- Codeforces Round #541 (Div. 2) E 字符串 + 思维 + 猜性质
https://codeforces.com/contest/1131/problem/D 题意 给你n个字符串,字符串长度总和加起来不会超过1e5,定义字符串相乘为\(s*s1=s1+s[0]+s1 ...
随机推荐
- Hibernate基本演示
保存一个对象到数据库中 目录结构 hibernate.cfg.xml <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hi ...
- [Leetcode] first missing positve 缺失的第一个正数
Given an unsorted integer array, find the first missing positive integer. For example,Given[1,2,0]re ...
- android脱壳之DexExtractor原理分析
导语: 上一篇我们分析android脱壳使用对dvmDexFileOpenPartial下断点的原理,使用这种方法脱壳的有2个缺点: 1. 需要动态调试 2. 对抗反调试方案 为了提高工作效率, ...
- [hdu 6069]素数筛+区间质因数分解
给[L,R]区间的每一个数都质因数分解的复杂度可以达到(R-L)logR,真的涨姿势…… 另外,质因数分解有很重要的一点,就是只需要打sqrt(R)以内的素数表就够了……因为超过sqrt(R)的至多只 ...
- oracle 数据库图形化工具 sqldeveloper
1. 安装完成Oracle数据库,点击左下角[开始]菜单,在所有程序中打开[Oracle] 2. 在开始菜单,展开Oracle数据库,安装文件,然后打开[应用程序开发].可以看到[sqldevelop ...
- The 'brew link' step did not complete successfully
在mac 上更新node时遇到了一系列的问题: 卸载node重新安装之后提示: The 'brew link' step did not complete successfully 其实这里已经给出了 ...
- centos7装机时更改网卡名为eth0操作
- Flex UI刷新后保持DataGrid中的ScrollBar的位置不变
这是之前我发的一个贴子问题描述:http://q.cnblogs.com/q/53469/
- sql注入预防
在我们登陆验证时会发现sql注入的现象. 1.sql注入发生原因 因为如果用户在用户名上输入的是' or 1=1 # 时,我们得到的sql语句是select * from shop_user wher ...
- bzoj1040 内向树DP
2013-11-17 08:52 原题传送门http://www.lydsy.com/JudgeOnline/problem.php?id=1040 N个骑士,每个人有一个仇人,那么,每个骑士只有一个 ...