9도 OJ 1093: WERTYU(번역)

시간 제한: 1초
메모리 제한: 32메가
특수 판제:아니오
제출: 1563
해결: 609
제목 설명:
    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 punctuation symbol by the one immediately to its left on the QWERTY keyboard shown above. Spaces in the input should be echoed in the output.
샘플 입력:
O S, GOMR YPFSU/

샘플 출력:
I AM FINE TODAY.

출처:
2006년 상해교통대학 컴퓨터 연구 생기 시험 진제
아이디어:
번역 문제, 세부 오류에 주의하세요.
코드:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
char keyboard[]={'`','1','2','3','4','5','6','7','8','9','0','-','=','Q','W','E','R','T','Y','U',
'I','O','P','[',']','\\','A','S','D','F','G','H','J','K','L',';','\'','Z','X','C','V','B','N','M',',','.','/'};
 
int main()
{
    char string[1000];
    int i,j;
 
    while(gets(string))
    {
        for(i = 0;i < strlen(string);i++){
            if(string[i] == ' '){
                printf(" ");
            }
            else{
                for(j = 0;j < strlen(keyboard);j++){
                    if(string[i] == keyboard[j]){
                        printf("%c",keyboard[j-1]);
                        break;
                    }
                }
            }
        }
        printf("
"); } return 0; } /************************************************************** Problem: 1093 User: liangrx06 Language: C Result: Accepted Time:0 ms Memory:912 kb ****************************************************************/

좋은 웹페이지 즐겨찾기