要写一个程序,用C或C++

来源:百度知道 编辑:UC知道 时间:2024/05/03 11:12:43
Description

Businesses like to have memorable telephone numbers. One way to make a telephone number memorable is to have it spell a memorable word or phrase. For example, you can call the University of Waterloo by dialing the memorable TUT-GLOP. Sometimes only part of the number is used to spell a word. When you get back to your hotel tonight you can order a pizza from Gino's by dialing 310-GINO. Another way to make a telephone number memorable is to group the digits in a memorable way. You could order your pizza from Pizza Hut by calling their ``three tens'' number 3-10-10-10.

The standard form of a telephone number is seven decimal digits with a hyphen between the third and fourth digits (e.g. 888-1200). The keypad of a phone supplies the mapping of letters to numbers, as follows:

A, B, and C map to 2
D, E, and F map to 3
G, H, and I map to 4
J, K, and L map to 5
M, N, and O map to 6
P, R, and S map to 7

#include <stdio.h>
#include <stdlib.h>

struct BITree
{
int number, no;
BITree *left, *right;
};

int mark;
BITree *head;

void insertnode (int k)
{
BITree *p, *np;

if (head == NULL)
{
head = (BITree *) malloc (sizeof (BITree));
head->number = k;
head->no = 1;
head->left = NULL;
head->right = NULL;
return;
}
p = head;
while (1)
{
if (p->number == k)
{
p->no++;
mark= 1;
return;
}

if (k < p->number)
{
if (p->left)
p = p->left;
else
{
np = (BITree *)malloc (sizeof (BITree));
np->number = k;
np->no = 1;
np->left = NULL;
np->right = NULL;
p->left = np;
return;
}
}

if (k > p->number)