模拟手机键盘

来源:互联网 发布:电子地图综合采集软件 编辑:程序博客网 时间:2024/04/27 18:01
http://acm.hust.edu.cn:8080/judge/problem/viewProblem.action?id=24245
Extraordinary Grid II
Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %lld & %llu

[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;}


原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 80岁老人植物人怎么办 steam账户创不起怎么办 小孩读书没有居住证怎么办 小孩上学没有准生证怎么办 小学在外地初中怎么办 小孩上学没准生证怎么办 没结婚出生证明怎么办 异地上高中高考怎么办 高中去外地上学怎么办 农村在城里上学怎么办? 父母没钱不工作怎么办 qq被家长偷看怎么办 孩子考差了怎么办 父母翻看qq记录怎么办 孩子qq屏蔽父母怎么办 杜鹃花老叶脱落怎么办 父母对孩子不好怎么办 家长看孩子手机怎么办 六年级打四年级学生怎么办 儿童被家长打怎么办 老师打孩子耳光怎么办 孩子动手打母亲怎么办 小孩被老师体罚怎么办 儿子跟父母对打怎么办 两个孩子争东西怎么办 大人吵架小孩该怎么办 小孩老爱顶嘴怎么办 孩子老爱顶嘴怎么办 孩子不愿分房睡怎么办 孩子不愿意去补课怎么办 高中孩子不愿意补课怎么办 孩子协调性不好怎么办 孩子暑假不愿意补课怎么办 话唠的孩子怎么办 孩孑不做作业怎么办 孩子有消极情绪怎么办 孩子太依赖奶奶怎么办 缺少母爱的孩子怎么办 孩子分房睡害怕怎么办 孩子厌烦写作业怎么办 孩子怕黑胆小怎么办