200分C++编程问题!

来源:百度知道 编辑:UC知道 时间:2024/06/06 01:50:47
是一个英文的题目,大意是要求做一个程序能够完成类似于手机键盘输入模块,按1次2输出a,连续按2次2输出b,然后还有些其他的要求。英文附在下面,多谢各位~~~

The diagram below shows the layout of a mobile phone keypad. Each key represents 3-4 lowercase letters and the digit associates with the key itself. To display a letter or a digit, a sequence of keystrokes is required. The table next to the keypad gives a few examples on how sms is produced by pressing the keys. Note that depending on the number of times a key is being pressed, there are more than one ways to display a letter or a digit. As for other keys in this keypad, key 0 produces a space in the sms, key 1 produce the digit '1', key * marks the end of the keystrokes, and the key # does not have any effect in the generation of sms. Keystrokes from user sms displayed (italics are comments, not the actual display)
2 a
22 b
222 c
2222 2
222222 b
888888888888 8
0

这道题有两种理解啊,一种是时间等待,另一种是输入-。
两种方案我都给你发到邮箱里去了,查收。
拿分,走人。

这个不难吧??

你要什么样的程序?
win32 还是控制台?

这个可能需要设置定时器~定时器不是C++标准里的东西,不知道可以不。
不用定时器就得用多线程。很简单的。

我英文学得不好。
你把这段话翻译成中文发给我,还要说清楚是要窗口程序还是控制台程序,我写了给你。
我邮箱:
zzzhiv@126.com

太简单了。

#include <stdio.h>
#include <conio.h>
#include <windows.h>

void main()
{
int chr,old=0,times;

while((chr=getch())!='*')
{
if(chr=='#')
{
continue;
}
else if(chr=='1')
{
times=0;
old=chr;
printf("%c",chr);
}
else if(chr=='2')
{
const char c2[]={'a','b','c','2'};

if(old!=chr)
{
old=chr;
times=0;
printf("%c",c2[times]);
}
else
{
times=(times+