1084. Broken Keyboard (20)

来源:互联网 发布:半自动咖啡机 知乎 编辑:程序博客网 时间:2024/06/06 21:01

浪费一个数组空间来存储是否已被输出

#include<cctype>#include<iostream>#include<string>#include<set>using namespace std;int main(){    int visited[1000] = {};    string a, b;    getline(cin, a);    getline(cin, b);    set<char> q;//存储输出的字符    for (auto x : b)        q.insert(toupper(x));    for (auto x : a)//对第一行的字符串进行逐个解析        if (q.find(toupper(x)) == q.end() && visited[toupper(x)]==0)        {            printf("%c",toupper(x));            visited[toupper(x)] = 1;        }    cout << endl;}
0 0
原创粉丝点击