ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1567. SMS-spam

To type “!”, press “0” three times. ?? should be four times, right?
Posted by Zhihua Lai 8 Apr 2010 06:15
Re: To type “!”, press “0” three times. ?? should be four times, right?
Posted by Zhihua Lai 8 Apr 2010 07:37
#include <iostream>

using namespace std;

int cnt(char ch)
{
    if ((ch >= 'a') && (ch <= 'z'))
    {
        return (((int)(ch - 'a') % 3) + 1);
    }
    switch (ch)
    {
        case '#': return (1); break;
        case ' ': return (2); break;
        case '0': return (1); break;
        case '.': return (2); break;
        case ',': return (3); break;
        case '!': return (4); break;
    }
    return (0);
}

int main()
{
    int n = 0;
    char ch;
    while (cin.get(ch))
    {
        n += cnt(ch);
    }
    cout << n << endl;
    return (0);
}

what is wrong with my code??? i got 122 at the sample test,,,,, could you help me ?? i cannot figure it out.. thanks..
Re: To type “!”, press “0” three times. ?? should be four times, right?
Posted by Zhihua Lai 8 Apr 2010 10:55
omg... my mistake in understanding the problem... got AC now....