- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
People who learned how to type before word processors often add two spaces after a period ending a sentence. Write a function singleSpaces that accepts a string and returns that string with all occurrences of two spaces after a "." into changed single spaces.)
这就是我所拥有的;我做错了什么?
#include <cmath>
#include <iostream>
using namespace std;
string forceSingleSpaces1 (string s) {
string r = "";
int i = 0;
while (i < static_cast <int> (s.length())) {
if (s.at(i) != ' ') {
r = r + s.at(i);
i++;
} else {
r += ' ';
while (i < static_cast <int> (s.length()) && s.at(i) == ' ')
i++;
}
}
return r;
}
最佳答案
在你的作业中有关于点后双空格的讨论,而不是文本中的所有双空格。所以你应该修改你的代码,让它
您可以将此代码视为两个状态机:
状态 1 - 当您在任何非 '.' 上循环时字符,在这种状态下,您的代码将添加所有它找到的结果
状态 2 - 是 '.' 时找到了,在这种状态下你使用不同的代码,你添加“。”结果和 ater 正好是一个空格(如果找到的话)
这样你就把你的问题分成了两个子问题
[edit] - 用修改提示替换源代码
关于c++ - 经期去除后的双倍空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10272991/
给定一个字符串"5 900 000" 我想通过以下模式使用 gsub 去除空格: gsub(/\s/, '') 但这似乎行不通。也没有: gsub(' ', '') 最佳答案 如果你想就地替换,你需要
我编写了一个程序来抓取网站以获取数据并输出到 Excel 表。该程序使用 Microsoft Visual Studio 2010 用 C# 编写。 大多数时候,我从网站获取内容、解析内容并将数据存储
在 MS Access 2007 项目报告中,我有以下(已编辑)查询: SELECT SomeCol FROM SomeTable 问题是, SomeCol 显然包含一些不可见的字符。例如,我看到一个
如 Removing left recursion 中所述,有两种方法可以去除左递归。 使用一些过程修改原始语法以删除左递归 写文法原来没有左递归 人们通常使用什么来删除(没有)ANTLR 的左递归?
我在 CoreData 中存储了一堆艺术家,并希望按名称对它们进行排序,但忽略前缀“the”。例如,“The Beatles”将被排序为“Beatles”,有点像 iTunes/iPod 的做法。 因
我有一个 WebView ,我想从中删除弹性。现在,当滚动小于 webview 的页面时,它会产生弹性效果,显示下面的背景。我想删除这个。 我尝试过执行以下操作,但没有成功。它找到了 WebDynam
我正在调查我们公司使用 Prometheus 从我们在 Kubernetes 上运行的实验中收集统计数据。有计划使用标签来标记我们的云/集群中特定实验的名称。这意味着我们将生成大量标签,这些标签会随着
我正在添加聚合物元素。我想在单击其(自己的)图像时删除元素(自我)。根据封装,我将不得不让 parent 删除 child 。但这也需要为母体生成聚合物元素(我在这里吗??)。 children.ad
现在如果我点击按钮 A,按钮 B 会显示 DropShadow 效果: Private Sub ButtonA_Click(ByVal sender As System.Object, ByVal
我尝试过这个,但它对我不起作用: char * remove_nl(char * newstr) { newstr = strdup(newstr); newstr[strlen(ne
我陷入了两难境地。我有一个图像,我想占据网页的背景。我希望它横跨屏幕的宽度和高度,并保持那个尺寸。当我使用 标签,我不知道如何将它拉伸(stretch)到没有白条的屏幕上。 wspace 和 hspa
Jade .foo .foo 结果 想要的结果 在 haml 中我会做类似 .foo>< 的事情但这在 Jade 中不起作用。我已经搜索并空手而归如何处理这个问题。我如何达到预期的结果
我是 Maven 的新手,当我尝试将我当前的项目从使用 Ant 转换为 -> 使用 Maven 时遇到了问题。 那个项目需要很多 Jar,我在 mvnrepository 上查找这些 jar 并将它们
我需要一个正则表达式来删除 xml 标记开头和结尾之间的空格。例如:有人创建 xml 并将其发送给我,这样我就可以验证、签名并发送到网络服务。 为此,我需要删除标签开头和结尾之间的空格: String
我写了几个方法来将项目添加到数组中,如果它们已经在数组中,它们将被忽略。在对数据结构做了一些研究之后,我意识到我可以通过简单地将它们放在一个集合中来摆脱重复(特别是因为我不关心对象的顺序)。然而,在玩
使用 HighCharts,我想移除 SVG 曲线上的抗锯齿。 到目前为止,我正在使用这个: $('path').each(function(i,j){$(j).attr('shape-renderi
由于某些奇怪的原因(黑色但不是黑色部分),我的 SeekBar 和拇指后面出现随机阴影。我该如何摆脱它? 我的搜索栏: 拇指.xml progress_appearance.xml(有一些
我有一个 Url,我想获取路径部分但没有尾随文件名。如果 Url 是 http://my.com/dir1/dir2/file.ext 那么我想获取 /dir1/dir2 . 我已经尝试了各种拆分(l
我有这个字符串: dataSourceURL = URL(string:"https://api.abc.com/api/p4/products?pid=uid8225&format=json&off
在我的网页中,我有一个菜单 (HorizontalPanel) 应该隐藏在页面的底部。为此,我尝试使用 RootLayoutPanel 类并在其中添加一个 south 小部件,我成功地做到了。但问
我是一名优秀的程序员,十分优秀!