2021-02-03

1084 Broken Keyboard (20 分)
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
大致思路:遍历输入串,先假设出现的字符键盘坏了,设置isbroken为true
遍历显示的串,显示过的字符对于的建没坏,故设置isbroken为false
再遍历输入串,isbroken为true的键为没显示出来的字符,如果该字符是小写,转换为大写即可
还有一个注意点,输出要去重,这里我用了unordered_set去重,由于unordered_set没有按插入顺序排列,故不能直接遍历set

#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<map>
#include<unordered_set>
using namespace std;
map<char,bool>isbroken;
unordered_set<char>ans;
string input,display;
int main()
{
    cin>>input>>display;
    for(char x:input){
        isbroken[x]=true;
    }
    for(char x:display){
        isbroken[x]=false;
    }
    for(char x:input){
        if(isbroken[x]==true){
            if('a'<=x&&x<='z'){
                x-=32;
                if(ans.insert(x).second==true){
                    printf("%c",x);
                }
            }
            else{
                if(ans.insert(x).second==true){
                    printf("%c",x);
                }
            }
        }
    }

    return 0;
}


【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现)内容概要:本文围绕使用MATLAB和XBee技术实现温度传感器无线网络的连续监控展开研究,介绍了如何构建无线传感网络系统,并利用MATLAB进行数据采集、处理与可视化分析。系统通过XBee模块实现传感器节点间的无线通信,实时传输温度数据至主机,MATLAB负责接收并处理数据,实现对环境温度的动态监测。文中详细阐述了硬件连接、通信协议配置、数据解析及软件编程实现过程,并提供了完整的MATLAB代码示例,便于读者复现和应用。该方案具有良好的扩展性和实用性,适用于远程环境监测场景。; 适合人群:具备一定MATLAB编程基础和无线通信基础知识的高校学生、科研人员及工程技术人员,尤其适合从事物联网、传感器网络相关项目开发的初学者与中级开发者。; 使用场景及目标:①实现基于XBee的无线温度传感网络搭建;②掌握MATLAB与无线模块的数据通信方法;③完成实时数据采集、处理与可视化;④为环境监测、工业测控等实际应用场景提供技术参考。; 阅读建议:建议读者结合文中提供的MATLAB代码与硬件连接图进行实践操作,先从简单的点对点通信入手,逐步扩展到多节点网络,同时可进一步探索数据滤波、异常检测、远程报警等功能的集成。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值