uva 10260 - Soundex
题目:编码翻译,有些字母有对应的数字,有的没有,如果连续对应的数字相同只输出一个。
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std; int rep( char c )
{
switch( c ) {
case 'B':
case 'F':
case 'P':
case 'V': return ;
case 'C':
case 'G':
case 'J':
case 'K':
case 'Q':
case 'S':
case 'X':
case 'Z': return ;
case 'D':
case 'T': return ;
case 'L': return ;
case 'M':
case 'N': return ;
case 'R': return ;
default : return ;
}
} int main()
{
char temp[];
while(cin >> temp)
{
for(int i=; temp[i]; ++i)
{
if(i> && rep(temp[i]) == rep(temp[i-])) continue;
if(!rep(temp[i])) continue;
cout << rep(temp[i]);
}
cout << endl;
}
return ;
}
uva 10260 - Soundex的更多相关文章
- uva 1354 Mobile Computing ——yhx
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5
- UVA 10564 Paths through the Hourglass[DP 打印]
UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...
- UVA 11404 Palindromic Subsequence[DP LCS 打印]
UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...
- UVA&&POJ离散概率与数学期望入门练习[4]
POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...
- UVA计数方法练习[3]
UVA - 11538 Chess Queen 题意:n*m放置两个互相攻击的后的方案数 分开讨论行 列 两条对角线 一个求和式 可以化简后计算 // // main.cpp // uva11538 ...
- UVA数学入门训练Round1[6]
UVA - 11388 GCD LCM 题意:输入g和l,找到a和b,gcd(a,b)=g,lacm(a,b)=l,a<b且a最小 g不能整除l时无解,否则一定g,l最小 #include &l ...
- UVA - 1625 Color Length[序列DP 代价计算技巧]
UVA - 1625 Color Length 白书 很明显f[i][j]表示第一个取到i第二个取到j的代价 问题在于代价的计算,并不知道每种颜色的开始和结束 和模拟赛那道环形DP很想,计算这 ...
- UVA - 10375 Choose and divide[唯一分解定理]
UVA - 10375 Choose and divide Choose and divide Time Limit: 1000MS Memory Limit: 65536K Total Subm ...
- UVA - 11584 Partitioning by Palindromes[序列DP]
UVA - 11584 Partitioning by Palindromes We say a sequence of char- acters is a palindrome if it is t ...
随机推荐
- 修改浏览器的User-Agent来伪装你的浏览器和操作系统
近期很多文章都提到了User-Agent (UA) 字符串,但大部分网友都不知道这个东西有什么用处.其实简单的说User-Agent就是客户端浏览器等应用程序使用的一种特殊的网络协议,在每次浏览器(邮 ...
- 黑马程序员——C语言开门片内存分析
iOS培训,iOS学习---------型技术博客.期待与您交流!------------ 一.各种进制的总结 1.二进制 (1) 在c语言中二进制以0b开头,输出二进制格式没有固定的格式,自定义输出 ...
- 无递归 A星寻路算法
整理硬盘的时候,发现我早些年写的A星寻路算法.特放上来,待有缘人拿去,无递归噢,性能那是杠杠的. 码上伺候 public class Node { public int X { get; set; } ...
- Android 之Service
service是运行在后台的服务,你可以启动一个服务Service来播放音乐,或者记录你地理信息位置的改变,或者启动一个服务来运行并一直监听某种动作. 接下来分析一下service 的生命周期: 1: ...
- mobile优化
原文: http://queue.acm.org/detail.cfm?id=2510122 译文: http://www.w3cfuns.com/forum.php?mod=viewthread&a ...
- VC++中调用cmd的集中方式
1. system方法: 原型: int __cdecl system(const char *); 例如: system("ipconfig"); 2. WinExec方法: 相 ...
- logstash multiline
filter { multiline { pattern => "^\s+%{TIMESTAMP_ISO8601}" negate=>true what=>&qu ...
- HDOJ 1334 Perfect Cubes(暴力)
Problem Description For hundreds of years Fermat's Last Theorem, which stated simply that for n > ...
- HDU_2032——杨辉三角
Problem Description 还记得中学时候学过的杨辉三角吗?具体的定义这里不再描述,你可以参考以下的图形:11 11 2 11 3 3 11 4 6 4 11 5 10 10 5 1 ...
- if(!!attr)是什么鬼???
看到很多代码if(!!attr),为什么不直接写if(attr):其实这是一种更严谨的写法:请测试 typeof 5和typeof !!5的区别.!!的作用是把一个其他类型的变量转成的bool类型.