1084. Broken Keyboard (20)

来源:互联网 发布:历代windows壁纸 编辑:程序博客网 时间:2024/05/04 16:37

1084. Broken Keyboard (20)

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

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.

Input Specification:

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.

Output Specification:

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.

Sample Input:
7_This_is_a_test_hs_s_a_es
Sample Output:
7TI
字符串的考查。还有一周左右就去考甲级了,拿之前的试题练练手,壮壮胆大哭

#include<iostream>#include<string>using namespace std;int main(){int i,j=0,t=0,m,flag;char c[80],c1[40];string str1,str2;string::iterator it1,it2;cin>>str1>>str2;it2=str2.begin();for(it1=str1.begin();it1!=str1.end();it1++){if((*it1)==(*it2)){it2++;}else{c[j++]=(*it1);}}for(i=0;i<j;i++){flag=0;if(c[i]>='a' && c[i]<='z')c[i]=c[i]-'a'+'A';if(t==0){c1[t++]=c[i];}else{for(m=0;m<t;m++){if(c[i]==c1[m])flag=1;}if(flag==0)c1[t++]=c[i];}}for(i=0;i<t;i++)cout<<c1[i];cout<<endl;return 0;}



0 0
原创粉丝点击