Uva 10082

  1. // Uva practice 10082
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6. string sList[4];
  7. sList[0] = "`1234567890-=";
  8. sList[1] = "QWERTYUIOP[]\\";
  9. sList[2] = "ASDFGHJKL;'";
  10. sList[3] = "ZXCVBNM,./";
  11. int iLength[4];
  12. iLength[0] = sList[0].length();
  13. iLength[1] = sList[1].length();
  14. iLength[2] = sList[2].length();
  15. iLength[3] = sList[3].length();
  16. string sIn;
  17. int i,j,k,p;
  18. while ( getline(cin,sIn) ) 
  19.     {
  20.     k = 0;
  21.     p = sIn.length();  
  22.     while ( k<)
  23.         {      
  24.         for ( i=0 ; i<4 ; i++ )
  25.             {
  26.             for ( j=0 ; j<iLength[i] ; j++)
  27.                 if ( sIn[k] == sList[i][j] )
  28.                     {
  29.                     if ( j-1 >= 0)
  30.                         cout << sList[i][j-1];
  31.                     else
  32.                         cout << sList[i][j+iLength[i]-1];      
  33.                     }
  34.             }
  35.         if ( (int)sIn[k] == 32 )
  36.             cout << " ";   
  37.         k++;
  38.         }  
  39.     cout << endl;
  40.     }  
  41. }

留言

這個網誌中的熱門文章

Codeforces --- string task

Uva 674 ---- coin change

codeforces 271A --- beautiful year