#include <iostream> #include <cstdlib> #include <string> using namespace std; bool isLongPressedStr(string origin,string typed) { //origin为原始字符串,typed为键盘键入的字符串 //在此处写入代码 } 本关任务: 键盘在长时间使用以后可能会产生粘连效应,即按压某个键位1次,但是会输入1个或多个重复的字符。 给你两个字符串origin和typed。origin为原始需要输入的单词,typed为实际上键盘键入的单词,请判断typed是否为origin所对应的单词,返回True或False 例如: origin="abcd",typed="aaabbcd" 返回True origin="aabcd",typed="abbbcccddd" 返回False。因为typed字符串中a应该至少出现2次
```cpp #include <iostream> #include <cstdlib> #include <string> using namespace std; bool isLongPressedStr(string origin, string typed) { int i = 0, j = 0; while (j < typed.length()) { if (i < origin.length() && origin[i] == typed[j]) { i++; j++; } else if (j > 0 && typed[j] == typed[j - 1]) { j++; } else { return false; } } return i == origin.length(); } ``` [2025-11-12 15:06:42 | AI问答 | 139点数解答]
相关提问
- [字节豆包] #include <iostream> #include <cstdlib> #include <string> using namespace std; bool isLongPressedStr(string origin,string typed) { //origin为原始字符串,typed为键盘键入的字符串 //在此处写入代码 } 本关任务: 键盘在长时间使用以后可能会产生粘连效应,即按压某个键位1次,但是会输入1个或多个重复的字符。 给你两个字符串origin和typed。origin为原始需要输入的单词,typed为实际上键盘键入的单词,请判断typed是否为origin所对应的单词,返回True或False 例如: origin="abcd",typed="aaabbcd" 返回True origin="aabcd",typed="abbbcccddd" 返回False。因为typed字符串中a应该至少出现2次(139点数解答 | 2025-11-12 15:06:42)22
- [字节豆包] #include <iostream> #include <sstream> #include <string> #include <cctype> #include <vector> // 将字符串转换为小写 std::string toLowerCase(const std::string& str) { std::string result = str; for (char& c : result) { c = std::tolower(c); } return result; } int main() { std::string target; std::getline(std::cin, target); target = toLowerCase(target); std::string article; std::getline(std::cin, article); std::stringstream ss(article); std::vector<std::(1381点数解答 | 2025-12-15 17:32:28)31
- [DeepSeek] using communication_protocols; using FTS_F02391A; using NLog; using ScottPlot.Plottable; using Sunny.UI; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespace 窗体界面设计 { public partial class FormHome : UIPage { private readonly DataLogger Log1;//波形图数据记录器 bool bViewSlide = false(562点数解答 | 2025-07-09 16:57:56)186
- [阿里通义] 修改代码#include <iostream> #include <string> #include <unordered_map> #include <ctime> #include <openssl/sha.h> #include <openssl/aes.h> #include <openssl/rand.h> #include <io.h> #include<process.h> #include <winsock2.h> // 处理可能未定义的socklen_t类型 #ifndef socklen_t typedef int socklen_t; #endif #define port 8080 #define otp_valid_time 120 // otp有效时间为2分钟 // 用户结构体 struct user { std::string username; std::string hashed_password; std::string otp; time_t otp_time; }; // 存储用户的哈希表 std::uno(465点数解答 | 2024-11-23 20:41:37)222
- [字节豆包] 输入一个三角形的3边长度,判断该三角形是否为直角三角形,若是则输出 true,若不是则输出 false。推荐做法:定义一个函数,接受三个 int 参数,返回 bool,再用主函数调用之。 编程要求 根据提示,在右侧编辑器补充代码。 测试说明 输入描述: 每行输入三个由空格隔开的整数 a, b, c,表示三角形的3条边长1 <= a,b,c<= 10000 输出描述: 对于每一行输入,输出 true 或者 false 表明是否为直角三角形 平台会对你编写的代码进行测试: 测试输入: 3 4 5 6 7 8 1 1 1 预期输出: true false false(222点数解答 | 2024-11-21 14:45:06)238
- [字节豆包] c语言输入一个三角形的3边长度,判断该三角形是否为直角三角形,若是则输出 true,若不是则输出 false。推荐做法:定义一个函数,接受三个 int 参数,返回 bool,再用主函数调用之。 编程要求 根据提示,在右侧编辑器补充代码。 测试说明 输入描述: 每行输入三个由空格隔开的整数 a, b, c,表示三角形的3条边长1 <= a,b,c<= 10000 输出描述: 对于每一行输入,输出 true 或者 false 表明是否为直角三角形 平台会对你编写的代码进行测试: 测试输入: 3 4 5 6 7 8 1 1 1 预期输出: true false false(307点数解答 | 2024-11-21 14:45:09)413
- [字节豆包] c语言输入一个三角形的3边长度,判断该三角形是否为直角三角形,若是则输出 true,若不是则输出 false。推荐做法:定义一个函数,接受三个 int 参数,返回 bool,再用主函数调用之。 编程要求 根据提示,在右侧编辑器补充代码。 测试说明 输入描述: 每行输入三个由空格隔开的整数 a, b, c,表示三角形的3条边长1 <= a,b,c<= 10000 输出描述: 对于每一行输入,输出 true 或者 false 表明是否为直角三角形 平台会对你编写的代码进行测试: 测试输入: 3 4 5 6 7 8 1 1 1 预期输出: true false false (340点数解答 | 2025-03-16 14:27:48)270
- [讯飞星火] #include <iostream> #include<cstring> using namespace std; class vehicle{ public: void run(); string getname(); vehicle(string name); string name; }; vehicle::vehicle(string name){ this->name = name; } void vehicle::run(){ cout<<"出发"<<endl; } string vehicle::getname(){ return name; } class car:public vehicle{ public: void break(); void display(); car(int seats,string color,string type,int power,string name); en(65点数解答 | 2024-05-26 17:01:16)342
- [GPT] #include <iostream> #include<cstring> using namespace std; class vehicle{ public: void run(); string getname(); vehicle(string name); string name; }; vehicle::vehicle(string name){ this->name = name; } void vehicle::run(){ cout<<"出发"<<endl; } string vehicle::getname(){ return name; } class car:public vehicle{ public: void break(); void display(); car(int seats,string color,string type,int power,string name); en(373点数解答 | 2024-05-26 17:02:18)330
- [字节豆包] #include "stm32f10x.h" // 有问题和需求的,可以联系VX:lwfw********* #include <stdio.h> #include <string.h> #include "sys.h" #include "delay.h" #include "OLED.h" #include "dht11.h" //温湿度传感器 #include "Key.h" #include "jidianqi.h" #include "OLED.h" #include "Serial.h" #include "LED.h" #include "Buzzer.h" #include "Motor.h" #include "CountSensor.h" #include "AD.h" uint16_t AD0; //存储ADC的值 uint8_t KeyNum; //存储按键值 uint8_t RxData; //蓝牙接收到的数据 u8 temp, humi; //存储温湿度 float temp1; //(25点数解答 | 2025-05-06 01:13:43)176
- [字节豆包] #include <iostream> #include <fstream> #include <vector> #include <string> #include <sstream> #include <stack> #include <map> #include <cctype> using namespace std; const string preamble = R"( .intel_syntax noprefix .globl main .extern printf .section .data format_str: .asciz "%d\n" .section .text main: push ebp mov ebp, esp sub esp, 208 )"; const string postamble = R"( mov eax, 0 mov esp, ebp pop ebp ret )"; struct Variable { char name; int offset; }; v(2430点数解答 | 2025-07-10 21:28:43)133
- [字节豆包] #include <iostream> #include <cstdlib> #include <string> using namespace std; int minDistance(string word1,string word2) { //在此处写入代码 } 本关任务: 编写一个函数来实现最短编辑距离计算方法。 编辑距离算法被数据科学家广泛应用,是用作机器翻译和语音识别评价标准的基本算法。 给你两个单词word1和word2(均为小写英文单词),请返回将word1转换成 word2所使用的最少操作数(编辑距离)。 你可以对一个单词进行如下三种操作: 插入一个字符 删除一个字符 替换一个字符 例如: word1 = "horse", word2 = "ros" 编辑距离=3 解释: horse -> rorse (将 'h' 替换为 'r') rorse -> rose (删除 'r') rose -> ros (删除 'e')(311点数解答 | 2025-11-12 14:55:49)41