题目要求
利用(2-abc,3-def,4-ghi,5-jkl,6-mno,7-pqrs,8-tuv,9-wxyz),记录电话号码,电话号码只有11位。通过把这些字母转化成数字。
4.2解决方法
在方法中一一表示出个字母所对应数字,输入字母,先将每行字母存入字符串数组中,再将每一行字符串数组转化为字符数组,通过该方法中的if-else语句将字母一一转化。
4.3程序
4.3.1 程序
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int n;
scanf("%d", &n);
while (n -- )
{
string s;
cin >> s;
for (int i = 0; i < s.size(); i++ )
{
int t = s[i];
if (t >= 'a' && t <= 'c') printf("2");
if (t >= 'd' && t <= 'f') printf("3");
if (t >= 'g