2012-09-30 107 views
-4

我想用c/C++编写一个程序,它从键盘的NUMERIC键盘输入整数输入,并且不显示屏幕上的输入,它应该显示没有任何延迟的字符输出。 像我们正在使用手机键盘打字。 eg..input:2223433 输出:CDGE数字小键盘到手机键盘模拟器..

222 = C,3 = d,4 =克,来自移动采取33 = E概念..

+0

你的问题是什么黑手党? –

+0

我想实现移动打字功能,就像在移动中我们按2显示'a',22显示'b',222显示'c'等。 – mafia

+2

酷。你的问题是什么,黑手党?你有什么企图,你在哪里遇到麻烦?我们帮助那些帮助自己的人。 –

回答

1

它并不难。但耗时。

你需要检查很多情况。例如,在一般的手机键盘中,从2到8只有3个字符被映射。但是在“9”键上映射了4个字符(即w,x,y,z)。并且还应该有一些预定义的延迟来检查。

int delayShort=x; 
int delayLong = y; 
while(numeric keys are pressed) 
{ 
    int ch = value of key pressed 
    switch(ch) 
    { 
     .............. 
     case 2: 
     if(another 2 is pressed within shortDelay time) 
      { 
       ch = (int) 'b'; 
       if(another 2 is pressed within shortDelay time) 
       { 
        ch = (int) 'c'; 
       } 
      } 
      else 
      { 
      ch ='a'; 
      } 
     ......................... 
     //    Handle other cases 

    } 
}