problem statement
Ad Hoc
Easily you have to convert each character in the input to its left character on the keyboard.
string kb = "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;\'ZXCVBNM,./";
while( getline(cin, line) )
{
for(int i = 0; i < line.size(); i ++)
cout << (line[i] != ' ' ? kb[ kb.find(line[i]) - 1 ] : ' ');
cout << endl;
}
In this solution I saved all the keyboard in a string named kb, and for each character, I find it in the string kb and print the previous character.
I use a good member function of class string, stringName.find( ch ) that return the position of ch in stringName or string::pos if ch is not in the string.
I describe my solution or give some hints about the solution for algorithmic problems used in ICPC or online sites for programming contests.
Friday, December 31, 2010
Subscribe to:
Post Comments (Atom)
USACO - Prime Palindromes
I just skimmed the problem statement and panicked of the high boundary of the input, but something inside told me don't worry everyth...
-
Prime Cryptarithm The following cryptarithm is a multiplication problem that can be solved by substituting digits from a specified set ...
-
Let's think about it, Have you noticed the small boundary of N & M, What can we do with this small boundary? Isn't producing al...
-
Dynamic Programming The problem wants to know in how many ways one can reach destination ( cell[width][height] ) If there were no obstacle...
No comments:
Post a Comment