UVA----10082 WERTYU【字符串】

版权声明:版权声明:本文为博主原创文章,转载请注明出处。 https://blog.csdn.net/YT201758501112/article/details/83713428

WERTYU

 UVA - 10082 

题目传送门

题目大意:按照所给的键盘样式,以及错误的字符串,输出正确的字符串,其输入的每一个字符都按照键盘样式向右错移了一位。

解决方法:将整个键盘用数组存起来,遍历一遍即可。

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <set>
#include <utility>
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define lep(i,l,r) for(int i=l;i>=r;i--)
#define ms(arr) memset(arr,0,sizeof(arr))
//priority_queue<int,vector<int> ,greater<int> >q;
const int maxn = (int)1e5 + 5;
const ll mod = 1e9+7;
char s[]={"`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./"};   //特别声明:“\”为特殊字符,需要加上转义字符“\”;
char c[maxn];
int main() 
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(0),cin.tie(0);
    int c;
    int j;
    while((c=getchar())!=EOF)
    {
    	for(j=0;s[j]&&s[j]!=c;j++);
    	if(s[j])
    		printf("%c",s[j-1]);
    	else
    		printf("%c",c);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/YT201758501112/article/details/83713428