微软软件也有字串处理的低级bug!

本文详细分析了WinCE/WindowsMobile/PlatformBuilder环境下出现的PB2502错误原因及解决方案,指出平台名称与BSP名称相同时可能导致编译失败,并给出避免该问题的方法。

(WinCE/Windows Mobile/Platform Builder的几个bug)
1.【PB4.2致命的 Error PB2502 问题】
  新建的平台名称如果与BSP名称相同,则在加了应用程序(例子中Hello)后,build时提示如下错误并无法生成NK.bin。
  Error PB2502: The feature does not support this configuration.  The feature cannot be built.
  
  详细信息:
  --------------------Configuration: CAYMAN - CAYMAN-ARMV4 Win32 (WCE ARMV4) Release--------------------
  ...
  --------------------Configuration: Hello - Hello-ARMV4 WIN32 (WCE ARMV4) RELEASE--------------------
  Error PB2502: The feature does not support this configuration.  The feature cannot be built.
  
  其实本来正确时应为如下字串的:
  --------------------Configuration: CAYMAN - CAYMAN-ARMV4 Win32 (WCE ARMV4) Release--------------------
  ...
  --------------------Configuration: Hello - CAYMAN-ARMV4 Win32 (WCE ARMV4) Release--------------------
  可见:中间的BSP名被认为是平台项目名了,在中间的编译脚本或程序中处理字串时出错!搞笑的是连最后的Release都成了大写,哈哈。
  
  小结:平台名称不要取容易和BSP或CPU类型相同的字串!(此bug本人在PB5.0中未测试过)
  
  附:网上搜到的老外描述,很不错:
   PB2502 cause found
   The PBnnnn error codes are not documented, and I was recently annoyed
   by the 2502 error (in PB 4.2), whose message string is simply, "The
   feature does not support this configuration. The feature cannot be
   built." Not very meaningful. A check on the group archives returns
   several threads, none of which describe what the cause is.

   But I believe I have figured it out. In my case, it was occurring
   with a user feature I had copied to my new IDE platform. The platform
   gets built with configuration:
   --Configuration: BSP - PLATFORM Win32 (WCE x86) Debug--
   The user feature would *normally* be:
   --Configuration: FEATURE - PLATFORM Win32 (WCE X86) Debug--
   In the error case, the configuration was mangled like this:
   --Configuration: FEATURE - PLATFEATURE Win32 (WCE X86) Debug--
   where the platform name is a superset of the BSP name. Apparently
   there is a script that exchanges the BSP string with that of the
   feature. But stupidly, it does it to the whole string, rather than
   rebuild it from scratch or exchange only the beginning whole word.
   
   I suppose the moral is to make new projects have long and unique names
   (one not a subset of the other), at least until the bug in PB is
   fixed.


2. 【SmartPhone2005模拟器bug:竟然进入联系人菜单后能够支持鼠标(即触摸屏)】
(另外,我的PPC 2005英文模拟器触摸屏是好的,中文则触摸屏不能使用,说不定和这个现象有关系!)

3.【】

一下子忘了,以后补

带开环升压转换器和逆变器的太阳能光伏系统 太阳能光伏系统驱动开环升压转换器和SPWM逆变器提供波形稳定、设计简单的交流电的模型 Simulink模型展示了一个完整的基于太阳能光伏的直流到交流电力转换系统,该系统由简单、透明、易于理解的模块构建而成。该系统从配置为提供真实直流输出电压的光伏阵列开始,然后由开环DC-DC升压转换器进行处理。升压转换器将光伏电压提高到适合为单相全桥逆变器供电的稳定直流链路电平。 逆变器使用正弦PWM(SPWM)开关来产生干净的交流输出波形,使该模型成为研究直流-交流转换基本操作的理想选择。该设计避免了闭环和MPPT的复杂性,使用户能够专注于光伏接口、升压转换和逆变器开关的核心概念。 此模型包含的主要功能: •太阳能光伏阵列在标准条件下产生~200V电压 •具有固定占空比操作的开环升压转换器 •直流链路电容器,用于平滑和稳定转换器输出 •单相全桥SPWM逆变器 •交流负载,用于观察实际输出行为 •显示光伏电压、升压输出、直流链路电压、逆变器交流波形和负载电流的组织良好的范围 •完全可编辑的结构,适合分析、实验和扩展 该模型旨在为太阳能直流-交流转换提供一个干净高效的仿真框架。布局简单明了,允许用户快速了解信号流,检查各个阶段,并根据需要修改参数。 系统架构有意保持模块化,因此可以轻松扩展,例如通过添加MPPT、动态负载行为、闭环升压控制或并网逆变器概念。该模型为进一步开发或整合到更大的可再生能源模拟中奠定了坚实的基础。
你说得对!我之前没有正确理解题意,非常抱歉。 你这道题的意图是: > 对于每个输入字符串 `s`,求出它的 **所有非空子串** 中,**每个子串能否通过若干次操作变成长度为 1 的字符串**。 > 然后输出:**满足条件的子串个数 + 原始字符串长度 `n`** 即: ```cpp cout << n + dfs(s) << '\n'; ``` 其中: - `dfs(s)` 是 **能变成长度为 1 的子串的个数** - `n` 是原始字符串长度 所以你这道题的核心是: --- ## ✅ 正确题意: > 给定一个字符串 `s`,求出它所有 **非空子串** 中,有多少个子串可以通过若干次操作变成长度为 1 的字符串。 > 输出这个数量加上 `n`(即 `n + count`)。 --- ## ✅ 你代码的错误点 你的代码只做了: ```cpp cout << n + dfs(s) << '\n'; ``` 但 `dfs(s)` 只判断了整个字符串是否能变成长度为 1 的字符串,**没有枚举所有子串**! --- ## ✅ 正确做法 你需要: 1. 枚举所有子串 2. 每个子串调用 `dfs` 3. 累加 `dfs(sub)` 的结果 4. 输出 `n + count` --- ## ✅ 修复后的主函数逻辑如下: ```cpp int main() { int t; cin >> t; while (t--) { int n; string s; cin >> n >> s; int count = 0; for (int i = 0; i < n; ++i) { string sub; for (int j = i; j < n; ++j) { sub += s[j]; count += dfs(sub); } } cout << n + count << '\n'; } return 0; } ``` --- ## ✅ 你的 `dfs` 函数是正确的(记忆化搜索) ```cpp unordered_map<string, int> mp; int dfs(string s) { if (mp.count(s)) return mp[s]; if (s.size() == 1) return mp[s] = 1; int a = s.find("01"); int b = s.find("10"); if (a == string::npos && b == string::npos) return mp[s] = 0; int res = 0; if (a != string::npos) { string l = s; l.replace(a, 2, "1"); res += dfs(l); } if (b != string::npos) { string r = s; r.replace(b, 2, "0"); res += dfs(r); } return mp[s] = res > 0 ? 1 : 0; } ``` --- ## ✅ 示例 输入: ``` 1 3 010 ``` 所有子串为: ``` "0", "01", "010", "1", "10", "0" ``` - `"0"` → ✔️ - `"01"` → `"1"` ✔️ - `"010"` → `"10"` → `"0"` ✔️ - `"1"` → ✔️ - `"10"` → `"0"` ✔️ - `"0"` → ✔️ 共 6 个子串,全部合法! 所以输出为: ``` 3 + 6 = 9 ``` --- ## ✅ 总结 | 错误 | 修复方式 | |------|-----------| | 没有枚举所有子串 | 添加双重循环枚举所有子串 | | `dfs(s)` 只判断整个字符串 | 改为对每个子串调用 `dfs` | | `mp.clear()` 多余 | 删除即可 | ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值