Uva-10082-Problem C: WERTYU

原创 2018年04月16日 21:11:39

Problem C: WERTYU

A common typing error is to place the hands on the keyboard one row to the right of the correct position. So "Q" is typed as "W" and "J" is typed as "K" and so on. You are to decode a message typed in this manner.

Input consists of several lines of text. Each line may contain digits, spaces, upper case letters (except Q, A, Z), or punctuation shown above [except back-quote (`)]. Keys labelled with words [Tab, BackSp, Control,etc.] are not represented in the input. You are to replace each letter or punction symbol by the one immediately to its left on the QWERTY keyboard shown above. Spaces in the input should be echoed in the output.

Sample Input

O S, GOMR YPFSU/

Output for Sample Input

I AM FINE TODAY.

思路:普通做法:恶心的一逼

#include<queue>
#include<stack>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    char a;
    while(scanf("%c",&a)!=EOF)
    {
        if(a=='=')printf("-");
        else if(a=='-')printf("0");
        else if(a=='0')printf("9");
        else if(a=='9')printf("8");
        else if(a=='8')printf("7");
        else if(a=='7')printf("6");
        else if(a=='6')printf("5");
        else if(a=='5')printf("4");
        else if(a=='4')printf("3");
        else if(a=='3')printf("2");
        else if(a=='2')printf("1");
        else if(a=='1')printf("`");
        else if(a=='\\')printf("]");
        else if(a==']')printf("[");
        else if(a=='[')printf("P");
        else if(a=='P')printf("O");
        else if(a=='O')printf("I");
        else if(a=='I')printf("U");
        else if(a=='U')printf("Y");
        else if(a=='Y')printf("T");
        else if(a=='T')printf("R");
        else if(a=='R')printf("E");
        else if(a=='E')printf("W");
        else if(a=='W')printf("Q");
        else if(a=='\'')printf(";");
        else if(a==';')printf("L");
        else if(a=='L')printf("K");
        else if(a=='K')printf("J");
        else if(a=='J')printf("H");
        else if(a=='H')printf("G");
        else if(a=='G')printf("F");
        else if(a=='F')printf("D");
        else if(a=='D')printf("S");
        else if(a=='S')printf("A");
        else if(a=='/')printf(".");
        else if(a=='.')printf(",");
        else if(a==',')printf("M");
        else if(a=='M')printf("N");
        else if(a=='N')printf("B");
        else if(a=='B')printf("V");
        else if(a=='V')printf("C");
        else if(a=='C')printf("X");
        else if(a=='X')printf("Z");
        else printf("%c",a);
    }
    return 0;
}

高级做法:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char s[]="`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";
int main(){
    char c;
    while((c=getchar())!=EOF){
        int i,j;
                bool flag = false;
            for(j=0;j<strlen(s);j++)
                if(c==s[j]){
                    flag=true;
                     putchar(s[j-1]);
                }
        if(flag==false)
            putchar(c);
    }
    return 0;
}

B - WERTYU——常量数组

think: 1常量数组运用 2getchar()和purchar()运用 3for循环结束的限制条件vjudge题目链接以下为accepted代码#include using namespac...
  • BlessingXRY
  • BlessingXRY
  • 2017-03-30 16:00:34
  • 194

算法入门经典:WERTYU

WERTYU(WERTYU, UVa 10082) 前言:好好努力! 问题: 把手放在键盘上时,稍不注意就会往右错一位。这样,输入Q会变成输入W,输入J会变成输入K等。        输入...
  • MissXy_
  • MissXy_
  • 2017-08-04 20:10:38
  • 652

【算法-字符串】【WERTYU】

把手放在键盘上时,稍不注意就会往右错一位。这样的话,Q会变成W,J会变成K等。 电脑键盘如图所示: 输入一个错位后敲出的字符串,输出打字员本来想打出的句子。 样例输入:O S, GOMR YPFS...
  • bear_huangzhen
  • bear_huangzhen
  • 2016-01-31 12:55:41
  • 603

UVA-10082 WERTYU

http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=19338 首先读入的整个字符串,是向右偏移了一位...
  • u012773338
  • u012773338
  • 2014-10-23 19:34:46
  • 371

UVa10082_WERTYU

10082 - WERTYU Time limit: 3.000 seconds
  • u013320038
  • u013320038
  • 2014-06-10 21:18:38
  • 560

B - WERTYU

此题大体意思是输入字符输出在键盘位置位于该字符前一位的字符例如输入W输出Q,输入E输出W。 思路: 定义一个常量数组char a[i],录入所有可能的键盘中的字符,然后每次输入字符控制与字符数组中每...
  • m0_37817220
  • m0_37817220
  • 2017-03-22 16:22:05
  • 115

《算法竞赛入门经典2ndEdition 》例题3-2 WERTYU(WERTYU, Uva10082)

这题主要就是用常量数组比较简便。下面这个是我第一开始写的,也AC了,但看过标程之后,感觉还是标程比较简洁。...
  • OccupiedCSDN
  • OccupiedCSDN
  • 2015-11-21 22:02:46
  • 298

3-2章

WPF编程设计指南读书笔记(3-2) 看一下System.Windows.Shapes命名空间,它包含了名为Shape的抽象类以及它的六个子类(Ellipse,Line,Path,Polygon,Po...
  • qpc411074777
  • qpc411074777
  • 2010-11-25 13:52:00
  • 266

HOJ 1853 WERTYU

http://acm.hit.edu.cn/hoj/problem/view?id=1853 输入字符 输出键盘上该字符左边的字符 #include char s[48]="`12345678...
  • epk_lee
  • epk_lee
  • 2012-11-23 23:21:36
  • 111

WERTYU (WERTYU, UVa10082)

A common typing error is to place the hands on the keyboard one row to the right of the correct posi...
  • sunlanchang
  • sunlanchang
  • 2017-01-13 12:38:43
  • 415
收藏助手
不良信息举报
您举报文章:Uva-10082-Problem C: WERTYU
举报原因:
原因补充:

(最多只允许输入30个字)