码迷,mamicode.com
首页 > 其他好文 > 详细

Programming Ability Test学习 1029. 旧键盘(20)

时间:2015-09-04 11:11:45      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:

1029. 旧键盘(20)

时间限制
200 ms
内存限制
65536 kB
代码长度限制
8000 B
判题程序
Standard
作者
CHEN, Yue

旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现。现在给出应该输入的一段文字、以及实际被输入的文字,请你列出肯定坏掉的那些键。

输入格式:

输入在2行中分别给出应该输入的文字、以及实际被输入的文字。每段文字是不超过80个字符的串,由字母A-Z(包括大、小写)、数字0-9、以及下划线“_”(代表空格)组成。题目保证2个字符串均非空。

输出格式:

按照发现顺序,在一行中输出坏掉的键。其中英文字母只输出大写,每个坏键只输出一次。题目保证至少有1个坏键。

输入样例:
7_This_is_a_test
_hs_s_a_es
输出样例:
7TI

提交代码

 

 

技术分享
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm> 
#define MAXSIZE 100005

using namespace std;

char *Divide(char *a)
{
    int leng=strlen(a);
    for(int i=0;i<leng;i++)//小写变为大写 
    {
        if(a[i]>=a&&a[i]<=z)
        a[i]=(char)(a[i] - (a - A));
    }
    int aa[300]={0};
    for(int j=0;j<leng;j++)
    {
        if(aa[a[j]]!=0)a[j]=*;
        aa[a[j]]++;
    }
    /*
    for(int j=1;j<leng;j++)
    {
        for(int i=0;i<j;i++)
        {
            if(a[j]==a[i])a[j]=‘*‘;
        }
    }*/
    return a;
} 


void Read(char *sst,char *sst1)
{
    int a[300]={0};
    for(int i=0;sst1[i];i++)
    {
        a[sst1[i]-0]=1;
    }
    for(int i=0;sst[i];i++)
    {
        if(a[sst[i]-0]==1)sst[i]=*;
    }
    int j=0;
    while(sst[j]!=\0)
    {
        if(sst[j]!=*)cout<<sst[j];
        j++;
    }
    cout<<endl;
    
}
int main()
{
    char ss[1000];char ss1[1000];

    gets(ss);
    char *sst=Divide(ss);
    //cout<<sst<<endl;
    gets(ss1);
    char *sst1=Divide(ss1);
    //cout<<sst1<<endl;
    
    //cout<<strlen(sst)<<" "<<strlen(sst1)<<endl;
    Read(sst,sst1);
    return 0;
} 
View Code

 

Programming Ability Test学习 1029. 旧键盘(20)

标签:

原文地址:http://www.cnblogs.com/a842297171/p/4781286.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!