Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
1.3 kB
3
Indexable
Never

void convert(char *s[], int count)
{
    for (int j = 0; j < count; j++)
    {
        char ans[100000] = {0};
        for (int i = 0; i < strlen(s[j]); i++)
        {
            if (s[j][i] != '\n')
            {
                if (s[j][i] == ' ')
                {
                    strcat(ans, " ");
                }
                else
                {
                    char cmd[] = {"(0)0"};
                    if (s[j][i] <= 'r')
                    {
                        cmd[1] = (2 + (s[j][i] - 'a') / 3 + '0');
                        cmd[3] = (1 + (s[j][i] - 'a') % 3 + '0');
                    }
                    else if (s[j][i] == 's')
                    {
                        cmd[1] = '7';
                        cmd[3] = '4';
                    }
                    else if (s[j][i] <= 'y')
                    {
                        cmd[1] = (2 + (s[j][i] - 'a' - 1) / 3 + '0');
                        cmd[3] = (1 + (s[j][i] - 'a' - 1) % 3 + '0');
                    }
                    else
                    {
                        cmd[1] = '9';
                        cmd[3] = '4';
                    }
                    strcat(ans, cmd);
                }
            }
        }
        strcat(ans, "\n");
        strcpy(s[j], ans);
    }
}