Message Decowding

From Progteam

Revision as of 18:35, 5 August 2008 by Mlc413 (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Checkmark.jpg This problem has been solved by mlc413.


Message Decowding
Problem Number 2141
Sorter: Uncategorized
Source: Unknown
Link: http://acm.pku.edu.cn/JudgeOnline/problem?id=2141



Message Decowding is problem number 2141 on the Peking University ACM site.



import java.util.*;

public class Main{
    public static Scanner in;
    public static void main(String[] args){
        in=new Scanner(System.in);

        doStuff();

    }

    public static void doStuff(){
        String cypher=in.nextLine();
        int [] decode = new int[26];
        for(int i = 0; i < 26; i++){
            decode[i]=(int)(cypher.charAt(i)-'a');
        }

        String message = in.nextLine();
        int len = message.length();
        for(int j = 0; j < len; j++){
            char ch=message.charAt(j);
            char newCh=ch;
            if(ch <= 'Z' && ch >= 'A'){
                newCh = (char)(decode[(int)(ch-'A')]+'A');
            }
            else if(ch <= 'z' && ch >= 'a'){
                newCh = (char)(decode[(int)(ch-'a')]+'a');
            }
            System.out.print(newCh);

        }
        System.out.println();

    }


}


Personal tools