Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

哪位高手帮忙看看 偶这个水平 太低 麻烦帮个忙吧

Posted by LIJITT at 2010-02-05 00:54:30 on Problem 1051
//问题1051

#include<iostream>

using namespace std;

int main(){
    string code;
    string code_out; 
    string c; 
    int number[101];  
    int num;
    int i; 
    
    cin>>num;
    
     while(num--){
                  cin>>code;
                  
                  for(i=0;i<code.size();i++){
                                             switch(code[i]){
                                                             case 'T':{number[i]=1;code_out += '0';break;}
                                                             case 'E':{number[i]=1;code_out += '1';break;}
                                                             case 'M':{number[i]=2;code_out += "00";break;}
                                                             case 'N':{number[i]=2;code_out += "01";break;}
                                                             case 'A':{number[i]=2;code_out += "10";break;}
                                                             case 'I':{number[i]=2;code_out += "11";break;}
                                                             case 'O':{number[i]=3;code_out += "000";break;}
                                                             case 'G':{number[i]=3;code_out += "001";break;}
                                                             case 'K':{number[i]=3;code_out += "010";break;}
                                                             case 'D':{number[i]=3;code_out += "011";break;}
                                                             case 'W':{number[i]=3;code_out += "100";break;}
                                                             case 'R':{number[i]=3;code_out += "101";break;}
                                                             case 'U':{number[i]=3;code_out += "110";break;}
                                                             case 'S':{number[i]=3;code_out += "111";break;}
                                                             case '?':{number[i]=4;code_out += "0000";break;}
                                                             case '.':{number[i]=4;code_out += "0001";break;}
                                                             case 'Q':{number[i]=4;code_out += "0010";break;}
                                                             case 'Z':{number[i]=4;code_out += "0011";break;}
                                                             case 'Y':{number[i]=4;code_out += "0100";break;}
                                                             case 'C':{number[i]=4;code_out += "0101";break;}
                                                             case 'X':{number[i]=4;code_out += "0110";break;}
                                                             case 'B':{number[i]=4;code_out += "0111";break;}
                                                             case 'J':{number[i]=4;code_out += "1000";break;}
                                                             case 'P':{number[i]=4;code_out += "1001";break;}
                                                             case ',':{number[i]=4;code_out += "1010";break;}
                                                             case 'L':{number[i]=4;code_out += "1011";break;}
                                                             case '_':{number[i]=4;code_out += "1100";break;}
                                                             case 'F':{number[i]=4;code_out += "1101";break;}
                                                             case 'V':{number[i]=4;code_out += "1110";break;}
                                                             case 'H':{number[i]=4;code_out += "1111";break;}
                                                             }
                                             }
                                             
                  for(i=0;i<code.size();i++){
                                             c = code_out.substr(i,number[code.size()-i-1]);
                                             switch(number[code.size()-i-1]){
                                                               case 1: {
                                                                    if(c[0] == '0'){
                                                                      code_out.replace(i,1,"T");
                                                                    }else{
                                                                          code_out.replace(i,1,"E");
                                                                          }
                                                               break;}
                                                               case 2: {
                                                                    if(c[0] == '0'){
                                                                            if(c[1] == '0'){
                                                                                     code_out.replace(i,2,"M");
                                                                                    }else{
                                                                                           code_out.replace(i,2,"N");
                                                                                          } 
                                                                    }else{
                                                                          if(c[1] == '0'){
                                                                                  code_out.replace(i,2,"A"); 
                                                                                  }else{
                                                                                        code_out.replace(i,2,"I"); 
                                                                                        }
                                                                          }
                                                                    break;}
                                                               case 3: {
                                                                    if(c[0] == '0'){
                                                                            if(c[1] == '0'){ 
                                                                                    if(c[2] == '0'){
                                                                                            code_out.replace(i,3,"O");
                                                                                            }else{
                                                                                                  code_out.replace(i,3,"G");
                                                                                                  }
                                                                                    }else{ 
                                                                                          if(c[2] == '0'){
                                                                                                  code_out.replace(i,3,"K");
                                                                                                  }else{
                                                                                                        code_out.replace(i,3,"D");
                                                                                                        }
                                                                                          }
                                                                            }else{
                                                                                  if(c[1] == '0'){
                                                                                          if(c[2] == '0'){
                                                                                                  code_out.replace(i,3,"W");
                                                                                                  }else{
                                                                                                        code_out.replace(i,3,"R");
                                                                                                        }
                                                                                          }else{
                                                                                                if(c[2] == '0'){
                                                                                                        code_out.replace(i,3,"U");
                                                                                                        }else{
                                                                                                              code_out.replace(i,3,"S");
                                                                                                              }
                                                                                                }
                                                                                  }
                                                                    break;}
                                                               case 4: {
                                                                    if(c[0] == '0'){
                                                                            
                                                                            if(c[1] == '0'){
                                                                                    
                                                                                    if(c[2] == '0'){
                                                                                      
                                                                                            if(c[3] == '0'){
                                                                                              
                                                                                                    code_out.replace(i,4,"?");
                                                                                                    }else{
                                                                                                     
                                                                                                          code_out.replace(i,4,".");
                                                                                                          }
                                                                                            }else{
                                                                                          
                                                                                                  if(c[3] == '0'){
                                                                                           
                                                                                                    code_out.replace(i,4,"Q");
                                                                                                    }else{
                                                                                                          code_out.replace(i,4,"Z");
                                                                                                          }
                                                                                                  }
                                                                                    }else{
                                                                                          if(c[2] == '0'){
                                                                                                  if(c[3] == '0'){
                                                                                                    code_out.replace(i,4,"Y");
                                                                                                    }else{
                                                                                                          code_out.replace(i,4,"C");
                                                                                                          }
                                                                                                  }else{
                                                                                                        if(c[3] == '0'){
                                                                                                    code_out.replace(i,4,"X");
                                                                                                    }else{
                                                                                                          code_out.replace(i,4,"B");
                                                                                                          }
                                                                                                        }
                                                                                          }
                                                                            }else{
                                                                                  if(c[1] == '0'){
                                                                                          if(c[2] == '0'){
                                                                                                  if(c[3] == '0'){
                                                                                                    code_out.replace(i,4,"J");
                                                                                                    }else{
                                                                                                          code_out.replace(i,4,"P");
                                                                                                          }
                                                                                                  }else{
                                                                                                        if(c[3] == '0'){
                                                                                                    code_out.replace(i,4,",");
                                                                                                    }else{
                                                                                                          code_out.replace(i,4,"L");
                                                                                                          }
                                                                                                        }
                                                                                          }else{
                                                                                                if(c[2] == '0'){
                                                                                                        if(c[3] == '0'){
                                                                                                    code_out.replace(i,4,"_");
                                                                                                    }else{
                                                                                                          code_out.replace(i,4,"F");
                                                                                                          }
                                                                                                        }else{
                                                                                                              if(c[3] == '0'){
                                                                                                    code_out.replace(i,4,"V");
                                                                                                    }else{
                                                                                                          code_out.replace(i,4,"H");
                                                                                                          }
                                                                                                              }
                                                                                                }
                                                                                  }
                                                                    break;}
                                                               }
                                             }
                     cout<<code_out<<endl;      
                     code_out.clear();                
                  }
    
    
    return 0;
} 

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator