UVA - 10921 - Problem B - Find the Telephone
来源:互联网 发布:envi处理sentinel数据 编辑:程序博客网 时间:2024/05/20 05:23
背景:
今天无意间在VJ-Status看到有人提交UVA的题目,还好是水题一枚,哈哈。
题意:
模拟手机九宫格输入法,把字母输入转换成数字输出。
输入类似“1-HOME-SWEET-HOME”。
输出类似“1-4663-79338-4663”。
分析:
其实是水题,完全不用分析,可本着"书写重新思考"的宗旨,再简单的东西也得认真把思路写一写!
因为完全是字符处理,放弃字符串方式。 → 直接逐个字符输入进行处理。
按照字符大小进行对应输出,因为没用else,所以得特别注意各if之间不会有重叠区间。
#include <iostream>#include <stdio.h>using namespace std;//#define LOCAL_TESTint main(){#ifdef LOCAL_TESTfreopen("..\\in.txt", "r", stdin);freopen("..\\out.txt", "w+", stdout);#endif// 尝试别用F盘路径了。用相对路径char ch;//while ( cin >>ch )// error, unable to get special character like 'enter'while ( (ch=cin.get()) != EOF ){if ( ch >= 'A' && ch <= 'O' )cout << (ch-'A')/3+2;if ( ch >='P' && ch<='S' )cout <<'7';if ( ch >='T' && ch<='V' )cout <<'8';if ( ch >='W' && ch<='Z' )cout <<'9';if ( ch<'A' || ch>'Z' )cout <<ch;} // end whilereturn 0;}
0 0
- UVA - 10921 - Problem B - Find the Telephone
- UVa 10921 - Find the Telephone
- UVA 10921 Find the Telephone
- UVa 10921 Find the Telephone (water ver.)
- B - The Blocks Problem UVA - 101
- The Telephone
- CF Find the problem
- B. Find The Bone
- UVA The Blocks Problem
- The Counting Problem UVA
- Problem G: Find The Difference
- Problem 389. Find the Difference
- UVA 11324 Problem B: The Largest Clique(强连通+DP,4级)
- UVA 4683 - Find The Number
- UVa 10219 - Find the ways !
- Find the Permutations [Uva 11077]
- 796B Find The Bone
- uva 101 the blocks problem
- 集合
- UVA - 10401 Injured Queen Problem
- live555基础概念【转】
- 学习笔记
- mysql无法创建存储过程(stored procedure
- UVA - 10921 - Problem B - Find the Telephone
- 动态规划程序设
- 查看linux系统是多少位,使用 getconf LONG_BIT echo $HOSTTYPE
- 体验缓冲区溢出
- BZOJ 1061 Noi2008 志愿者招募 单纯形
- UVA - 10891 Game of Sum
- Java自学总结之二关于重载、继承与多态
- 继续学习angular js
- Spring对静态资源文件的访问