Codeforces
来源:互联网 发布:浙江省纺织品出口数据 编辑:程序博客网 时间:2024/06/12 00:08
B. Keyboard Layouts
题目链接
分类:字符串、模拟
1.题意概述
- 给你26个字母的映射(均为小写),再给你一串长度不大于1000的字符串,要你输出它的映射结果。
2.解题思路
- map直接存,注意的是大写变换以后还是大写,还有数字不需要映射!
3.AC代码
#include <bits/stdc++.h>#define INF 0x3f3f3f3f#define maxn 100010#define lson root << 1#define rson root << 1 | 1#define lent (t[root].r - t[root].l + 1)#define lenl (t[lson].r - t[lson].l + 1)#define lenr (t[rson].r - t[rson].l + 1)#define N 1111#define eps 1e-6#define pi acos(-1.0)#define e exp(1.0)#define Close() ios::sync_with_stdio(0),cin.tie(0)using namespace std;const int mod = 1e9 + 7;typedef long long ll;typedef unsigned long long ull;map<int, int> mp;char s1[28], s2[28], ch[N];int main(){#ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); long _begin_time = clock();#endif scanf("%s%s", s1, s2); for (int i = 0; i < 26; i++) { char a = s1[i], b = s2[i]; mp[a - 'a'] = b - 'a'; } scanf("%s", ch); int len = strlen(ch);// printf("%s\n", ch); for (int i = 0; i < len; i++) { if ('0' <= ch[i] && ch[i] <= '9') { putchar(ch[i]); continue; } char c = ch[i]; bool uppercase = 0; if (c <= 'Z') { uppercase = 1; c -= 'A'; } else c -= 'a'; int ans = mp[c]; if (uppercase) putchar(ans + 'A'); else putchar(ans + 'a'); } puts("");#ifndef ONLINE_JUDGE long _end_time = clock(); printf("time = %ld ms.", _end_time - _begin_time);#endif return 0;}
阅读全文
0 0
- codeforces~~~
- Codeforces
- codeforces
- Codeforces
- codeforces
- codeforces
- Codeforces
- Codeforces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- java基础易错题
- 深入理解 Android 之 View 的绘制流程(一)
- Python联系笔记2[列表,元组,集合,字典,函数,文件操作,模块,类]
- Python:序列化二叉树
- KS109的STM32的移植
- Codeforces
- 单点LDAP安装配置
- 使用JVisualVM远程监控Tomcat
- 解决The current branch is not configured for pull No value for key branch.master.merge found in config
- Codeforces Round #423 (Div. 1, rated, based on VK Cup Finals) D. Best Edge Weight(最小生成树+LCA+树链剖分)
- Python-matplotlib基本操作
- 冒泡排序
- git clone出现fatal: unable to access 'https://': SSL certificate problem: self signed certificate in
- linux C 读二进制文件和文件读取