[算法竞赛入门]WERTYU

【题目描述】

UVa Online Judge 10082

【解析】

此题没什么难度,主要还是strchr的使用和index的计算。

【一种实现方式】

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>

using namespace std;

int main(){
    char input[] = "`1234567890-=QWERTYUIOP[]ASDFGHJKL;'ZXCVBNM,./";
    char c;
    while((c = getchar()) != EOF){
        if(NULL != strchr(input, c)){
            cout << input[strchr(input, c) - input - 1];
        }
        else{
            cout << c;
        }
    }
    return 0;
}

注:原创博客,转载请注明。

原文地址:https://www.cnblogs.com/Vivianwang/p/6437457.html