zoukankan      html  css  js  c++  java
  • uva10082 WERTYU (Uva10082)

    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/

    Sample Output

    I AM FINE TODAY.
    这个题的意思是说输入一串已经往右移一位的字符串然后输出原来正确的字符串。
    代码
     1 #include <iostream>
     2 //#include "fp.h"
     3 using namespace std;
     4 char s[]="`1234567890-=QWERTYUIOP[]\ASDFGHJKL;'ZXCVBNM,./";
     5 main()
     6 {
     7     //fop();
     8     char c;int i;
     9     while((c=getchar())!=EOF)
    10     {
    11         for( i=1;s[i]&&s[i]!=c;i++);
    12         if(s[i]) 
    13         putchar(s[i-1]);
    14         else 
    15         putchar(c);
    16     }
    17 }
    
    

    这个题要求注意的东西我觉得还挺多的,首先需要了解一下用数组去记录内容的一种方法。

    for( i=1;s[i]&&s[i]!=c;i++);这一行我之前就写错把下面的一堆语句写在了这个for里面,然后我基本学完了紫书的情况下,居然还是写错了一次。。。

    (这段代码是真的很强,把每个输入进来的s[i]都进行了重新的定位真的是佩服佩服)

    原来不明白的条件s[i]现在也明白了,是个很巧的方法,我们没有去数究竟有多少个数在字符串数组里面,我们就用一个s[i]因为如果越界s[i]应该都是0(待实验)

    其他的跟上一个题基本是一样的了。

     

     
  • 相关阅读:
    ANC耳机中的数字反馈稳定性控制(Active Noise Cancellation in Headphones by Digital Robust Feedback Control)
    【控制理论】水床效应(waterbed effect)与Bode灵敏度积分
    ANC的基本概念 主通路和次级通路
    ANC耳机中通透模式设计方案
    matlab编程规则总结
    滤波器系数、单位脉冲响应、频率响应等概念笔记
    shell 脚本艺术
    vue leader-line-vue
    vue npm rum命令
    VUEX
  • 原文地址:https://www.cnblogs.com/baccano-acmer/p/9717981.html
Copyright © 2011-2022 走看看