2012-09-30 103 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 

    } 
}