Nyoj 223 Xiao Ming's troubles

Source: Internet
Author: User
Xiao Ming's troublesTime limit: Ms | Memory limit: 65535 KB Difficulty: 1 description Xiao Ming recently received a tricky task, their company has a phone book. But this is a strange phone book, because it does not use numbers to record phone numbers, but instead uses the letters corresponding to the number keys to record phone numbers (2-abc,3-def,4-ghi , 5-JKL,6-MNO,7-PQRS,8-TUV,9-WXYZ), the phone number is only 11 digits. Now your task is to help Xiaoming to write a program to convert these letters to digital phone numbers. Enter the first line to enter a positive integer T (0<t<=100) that represents the number of groups of test data
Each set of test data has only one row, enter a string of characters (character length is 11), output each set of output is a row, the output number of the phone number sample input
3
phqghumeayl
Nlfdxfircvs
cxggbwkfnqd
Sample output
74744863295
65339347287
29442953673

Idea: Actually this question and 198 questions are the same, directly constructs an array to access the array element is good

#include <stdio.h>

int main ()
{
	int N;
	Char table[] = "22233344455566677778889999";
	scanf ("%d", &n);
	while (n--)
	{
		char s[12];
		int i;
		scanf ("%s", s);
		for (i=0; s[i]! = ' + '; i++)
		{
			printf ("%c", table[s[i]-' a ']);
		}

		printf ("\ n");}
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.