模拟手机键盘
来源:互联网 发布:电子地图综合采集软件 编辑:程序博客网 时间:2024/04/27 18:01
[Submit] [Go Back] [Status]
Description
She loves e-mail so much! She sends e-mails by her cellular phone to her friends when she has breakfast, she talks with other friends, and even when she works in the library! Her cellular phone has somewhat simple layout (Figure 1). Pushing button 1 once displays a character (’), pushing
it twice in series displays a character (,), and so on, and pushing it 6 times displays (’) again. Button 2 corresponds to charaters (abcABC), and, for example, pushing it four times displays (A). Button 3-9 have is similar to button 1. Button 0 is a special button: pushing it once make her possible to input characters in the same button in series. For example, she has to push “20202” to display “aaa” and “660666” to display “no”. In addition, pushing button 0 n times in series (n > 1) displays n − 1 spaces. She never pushes button 0 at the very beginning of her input. Here are some examples of her input and output:
666660666 --> No44444416003334446633111 --> I’m fine.20202202000333003330333 --> aaba f ff
One day, the chief librarian of the library got very angry with her and hacked her cellular phone when she went to the second floor of the library to return books in shelves. Now her cellular phone can only display button numbers she pushes. Your task is to write a program to convert the sequence of button numbers into correct characters and help her continue her e-mails!
Input
Input consists of several lines. Each line contains the sequence of button numbers without any spaces. You may assume one line contains no more than 10000 numbers. Input terminates with EOF.
Output
For each line of input, output the corresponding sequence of characters in one line.
Sample Input
6666606664444441600333444663311120202202000333003330333
Output for the Sample Input
NoI'm fine.aaba f ff
#include <iostream>#include <cstdio>#include <stdlib.h>#include <cstring>using namespace std;#define N 100int n;int a[N][N];int r[N],c[N];int flag[N][N];int ans[201];int p=0;int main(){while(scanf("%d",&n)!=EOF && n){p=0;memset(flag,0,sizeof(flag));int i,j;for(i=0;i<n;i++)for(j=0;j<n;j++)scanf("%d",&a[i][j]);int min,max;int temp;for(i=0;i<n;i++){min=0x7fffffff;for(j=0;j<n;j++)if(min>a[i][j]){min=a[i][j];temp=j;}r[i]=temp;}for(j=0;j<n;j++){max=0x7ffffffe;max=-max;for(i=0;i<n;i++)if(max<a[i][j]){max=a[i][j];temp=i;}c[j]=temp;}for(i=0;i<n;i++){//printf("%d ",r[i]);flag[i][r[i]]++;}for(i=0;i<n;i++){//printf("%d ",c[i]);flag[c[i]][i]++;}/*for(i=0;i<n;i++){for(j=0;j<n;j++)printf("%d ",flag[i][j]);printf("\n");}*/int b=0;for(i=0;i<n;i++){for(j=0;j<n;j++)if(flag[i][j]==2)ans[p++]=a[i][j];}if(p==0)printf("0\n");elsefor(i=0;i<p;i++)printf("%d",ans[i]);printf("\n");}return 0;}
- 模拟手机键盘
- 模拟_题目1079:手机键盘
- 九度OJ 1079 手机键盘 (模拟)
- 键盘模拟
- 键盘模拟
- 键盘模拟
- 模拟键盘
- 模拟键盘
- 手机键盘
- 手机键盘
- 手机键盘
- 手机键盘
- 手机键盘
- 手机键盘
- 手机键盘
- 手机键盘
- 手机键盘
- 手机键盘
- 程序员进阶书籍
- cvConvertScale用法
- STL 容器和迭代器连载4_顺序容器的操作1
- STL 容器和迭代器连载5_顺序容器的操作2
- NYOJ35 表达式求值
- 模拟手机键盘
- zend stuido 9.0 php 5.3.8 xdebug 2.2
- C语言中,你不得不知的位运算符特性
- js 获取当前url
- listener.ora、sqlnet.ora、tnsnames.ora 作用
- VSS, VDD, VEE, VCC 区别
- Apache配置多站点
- 破解入门(一)-----常用寄存器
- Struts2 采用convention-plugin实现零配置