题目描写叙述

On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters 

corresponding to those keys will not appear on screen.

Now given a string that you are supposed to type, and the string that you actually type out, please list those keys 

which are for sure worn out.

输入描写叙述:

Each input file contains one test case. For each case, the 1st line contains the original string, and the 2nd line contains the typed-out string. Each string contains 

no more than 80 characters which are either English letters [A-Z] (case 

insensitive), digital numbers [0-9], or "_" (representing the space). It is guaranteed that both strings are non-empty.

输出描写叙述:

For each test case, print in one line the keys that are worn out, in the order of being detected. The English letters must be capitalized. 

Each worn out key must be printed once only. It is guaranteed that there is at least one worn out key.

输入样例:

7_This_is_a_test

_hs_s_a_es

输出样例:

7TI

#include<iostream>
#include <cstring>
#include <cstdlib>
#include <string> using namespace std; const int MAX=80; //去掉字符串中反复的字符
void Remove(char* s, int num)
{
int i,j,l;
i=j=0;
for(i=0;i<num;i++)
{
for(l=0;l<j;l++)
{
if(s[l]==s[i])
break;
}
if(l>=j)
{
s[j++]=s[i];
}
}
s[j]='\0';
} //找出第1个字符串中,没有在第2个字符串中出现的字符。
void Worn(char* lhs, char* rhs, char* result)
{
int i,j,k;
k=0;
for(i=0;lhs[i]!='\0';i++)
{
for(j=0;rhs[j]!='\0';j++)
{
if(lhs[i]==rhs[j])
break;
}
if(rhs[j]=='\0')
{
result[k++]=lhs[i];
}
}
result[k]='\0';
} int main()
{
int i;
string n,m;
char sn[MAX],sm[MAX],sr[MAX];
while(cin>>n>>m)
{
//将输入的字符串1中的小写英文字符转换为大写英文字符
for(i=0;i<n.length();i++)
{
sn[i]=n[i];
if((sn[i]>=65)&&(sn[i]<=90) || (sn[i]>=97)&&(sn[i]<=122))
sn[i]=::toupper(sn[i]);
}
sn[i]='\0'; //将输入的字符串2中的小写英文字符转换为大写英文字符
for(i=0;i<m.length();i++)
{
sm[i]=m[i];
if((sm[i]>=65)&&(sm[i]<=90) || (sm[i]>=97)&&(sm[i]<=122))
sm[i]=::toupper(sm[i]);
}
sm[i]='\0'; /*
for(i=0;sn[i]!='\0';i++)
cout<<sn[i]<<" ";
cout<<endl; for(i=0;sm[i]!='\0';i++)
cout<<sm[i]<<" ";
cout<<endl;
*/ Remove(sn,n.length());
Remove(sm,m.length()); Worn(sn,sm,sr); for(i=0;sr[i]!='\0';i++)
cout<<sr[i];
cout<<endl;
}
return 0;
}

PAT Broken Keyboard (20)的更多相关文章

  1. 1084. Broken Keyboard (20)【字符串操作】——PAT (Advanced Level) Practise

    题目信息 1084. Broken Keyboard (20) 时间限制200 ms 内存限制65536 kB 代码长度限制16000 B On a broken keyboard, some of ...

  2. pat1084. Broken Keyboard (20)

    1084. Broken Keyboard (20) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue On a ...

  3. PAT Advanced 1084 Broken Keyboard (20) [Hash散列]

    题目 On a broken keyboard, some of the keys are worn out. So when you type some sentences, the charact ...

  4. 1084. Broken Keyboard (20)

    On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters ...

  5. PAT (Advanced Level) 1084. Broken Keyboard (20)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  6. 【PAT甲级】1084 Broken Keyboard (20 分)

    题意: 输入两行字符串,输出第一行有而第二行没有的字符(对大小写不敏感且全部以大写输出). AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #inclu ...

  7. 1084. Broken Keyboard (20)-水题

    #include <iostream> #include <cstdio> #include <string.h> #include <algorithm&g ...

  8. PAT 1084 Broken Keyboard

    1084 Broken Keyboard (20 分)   On a broken keyboard, some of the keys are worn out. So when you type ...

  9. PAT_A1084#Broken Keyboard

    Source: PAT A1084 Broken Keyboard (20 分) Description: On a broken keyboard, some of the keys are wor ...

随机推荐

  1. SQL生僻字模糊查询

    生僻字指在数据库默认的编码中不存 又称难字或冷僻字 一.SQL中解决生僻字录入乱码问题[调整列数据类型->由varchar改为NVARCHAR]

  2. 简单的css缩放动画,仿腾讯新闻的分享按钮和美团app底部的图标样式

    最近看到一些好看的hover的图形缩放效果.然后自己就写了下,发现这2种效果都不错.如果伙伴们更好的实现方式可以在下面留言哦~ 还有美团的效果,我就不展示了,喜欢的可以去app应用上看看. 这两种效果 ...

  3. 通过重写.htaccess文件添加404

    如果说是用linux服务器的系统 想要给自己的网站设置404怎么弄?如果你不会给自己的Ecs服务器添加服务器管理系统,或是你购买的云虚拟主机没有304.404设置,那么就要通过自己重写文件来设置404 ...

  4. 360 你妈妈知道你跟Python存在兼容问题吗?

    最近在用Python2.7.6版本开发的的过程中发现了一个问题 提示:UnicodeDecodeError:'ascii' codec can't decode bytes 0xb0 刚开始以为是编码 ...

  5. CherryPy 入门

    CherryPy是一个Python的HTTP框架,可以用Python来处理HTTP请求然后返回结果. 1. 安装 可以去这个地址下载 CherryPy-3.1.2.win32.exe .或者去这个链接 ...

  6. vps 虚拟服务器 教程 ( Virtual Private Server 虚拟专用服务器 )

    VPS是虚拟服务器的意思.他是通过软件在独立服务器上划分出来的一部分资源.从而虚拟出一个服务器.他拥有独立的IP.独立的操作系统.以及用户名和密码.在功能和使用方法上与服务器一模一样.用户也可以根据自 ...

  7. Django之auth登录认证

    前言:我们在开发一个网站的时候,无可避免的需要设计实现网站的用户系统.此时我们需要实现包括用户注册.用户登录.用户认证.注销.修改密码等功能,这还真是个麻烦的事情呢. Django作为一个完美主义者的 ...

  8. OpenGL坐标系之间的转换 http://blog.csdn.net/sac761/article/details/52179585

    1. OpenGL 渲染管线 OpenGL渲染管线分为两大部分,模型观测变换(ModelView Transformation)和投影变换(Projection Transformation).做个比 ...

  9. 攻破javascript面试的完美指南【译】

    攻破javascript面试的完美指南(开发者视角) 0. 前言 本文适合有一定js基础的前端开发人员阅读.原文是我google时无意发现的, 被一些知识点清晰的解析所打动, 决定翻译并记录下来.这个 ...

  10. 洛谷——P1168 中位数

    P1168 中位数 题目描述 给出一个长度为NN的非负整数序列$A_i$​,对于所有1 ≤ k ≤ (N + 1),输出$A_1, A_3, …, A_{2k - 1}A1​,A3​,…,A2k−1​ ...